choose_self_exe Function

private function choose_self_exe(exe0) result(exe)

Determine the executable to use when spawning the child watcher.

Precedence: 1. Explicit exe0 argument 2. Environment FPM_WATCH_SELF 3. argv[0] 4. Fallback "fpm-watch"

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: exe0

Return Value character(len=:), allocatable


Calls

proc~~choose_self_exe~~CallsGraph proc~choose_self_exe choose_self_exe proc~get_arg get_arg proc~choose_self_exe->proc~get_arg

Called by

proc~~choose_self_exe~~CalledByGraph proc~choose_self_exe choose_self_exe proc~build_child_command build_child_command proc~build_child_command->proc~choose_self_exe proc~supervisor_loop supervisor_loop proc~supervisor_loop->proc~build_child_command proc~maybe_supervise maybe_supervise proc~maybe_supervise->proc~supervisor_loop

Source Code

   function choose_self_exe(exe0) result(exe)
      character(len=*), intent(in) :: exe0
      character(len=:), allocatable :: exe
      character(len=2048) :: buf
      integer :: n, stat
      character(len=:), allocatable :: a0

      if (len_trim(exe0) > 0) then
         exe = trim(exe0)
         return
      end if

      buf = ""
      n = 0
      stat = 0
      call get_environment_variable("FPM_WATCH_SELF", buf, length=n, status=stat)
      if (stat == 0 .and. n > 0) then
         exe = trim(buf(1:n))
         return
      end if

      a0 = get_arg(0)
      if (len_trim(a0) > 0) then
         exe = trim(a0)
         return
      end if

      exe = "fpm-watch"
   end function choose_self_exe