build_child_command Function

private function build_child_command(exe0) result(cmd)

Build the command line used to spawn the supervised child.

The child receives --watch-child and inherits most argv tokens, with supervisor-only flags removed to avoid recursion.

Arguments

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

Return Value character(len=:), allocatable


Calls

proc~~build_child_command~~CallsGraph proc~build_child_command build_child_command proc~choose_self_exe choose_self_exe proc~build_child_command->proc~choose_self_exe proc~get_arg get_arg proc~build_child_command->proc~get_arg proc~quote_arg quote_arg proc~build_child_command->proc~quote_arg proc~starts_with~2 starts_with proc~build_child_command->proc~starts_with~2 proc~choose_self_exe->proc~get_arg proc~is_windows_os is_windows_os proc~quote_arg->proc~is_windows_os get_os_type get_os_type proc~is_windows_os->get_os_type

Called by

proc~~build_child_command~~CalledByGraph proc~build_child_command build_child_command 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 build_child_command(exe0) result(cmd)
      character(len=*), intent(in) :: exe0
      character(len=:), allocatable :: cmd
      character(len=:), allocatable :: exe, a
      integer :: narg, i
      logical :: skip_next

      exe = choose_self_exe(exe0)
      cmd = quote_arg(exe) // " --watch-child"

      narg = command_argument_count()
      skip_next = .false.

      do i = 1, narg
         a = get_arg(i)

         if (skip_next) then
            skip_next = .false.
            cycle
         end if

         if (a == "--watch-auto-restart") cycle
         if (a == "--watch-child") cycle

         if (a == "--watch-restart-delay") then
            skip_next = .true.
            cycle
         end if
         if (a == "--watch-restart-max") then
            skip_next = .true.
            cycle
         end if
         if (a == "--watch-self") then
            skip_next = .true.
            cycle
         end if

         if (starts_with(a, "--watch-restart-delay=")) cycle
         if (starts_with(a, "--watch-restart-max=")) cycle
         if (starts_with(a, "--watch-self=")) cycle

         cmd = cmd // " " // quote_arg(a)
      end do
   end function build_child_command