On Fri, 2009-08-14 at 22:19 +0100, Dave Korn wrote:
> Laurent GUERBY wrote:
> 
> > 3/ Here is the point I find surprising: the "ps fauxww" run in the
> > second "if" show that even if the script is fully sequential
> > at least one gnatmake subprocess (collect-ld) is still marked as running 
> > *in parallel* with the ps command in the subsequent "if" of the script!
> 
> > Any idea of why /bin/sh is running stuff in parallel instead
> > of sequential? 
> > 
> > Could some code in 
> > gnatmake/gnatlink/xgcc/collect2/collect-ld cause it?
> 
>   I notice gnatmake.adb has a reference to GNAT.OS_Lib.Non_Blocking_Spawn in
> it.... coincidence?

gnatmake uses Non_Blocking_Spawn to call the compiler (gnatmake supports
"-j N" like make), but for the gnatlink call (we see in the "ps fauxww")
it uses in gcc/ada/make.adb:

   procedure Link
...
      GNAT.OS_Lib.Spawn (Gnatlink_Path.all, Link_Args, Success);
   end Link;

which ends up calling gcc/ada/s-os_lib.adb

      Spawn_Internal (Program_Name, Args, Result, Junk, Blocking =>
True);
...
         function Portable_Spawn (Args : Address) return Integer;
         pragma Import (C, Portable_Spawn, "__gnat_portable_spawn");

which ends up calling in gcc/ada/adaint.c:

int
__gnat_portable_spawn (char *args[])
...
  pid = fork ();
  if (pid < 0)
    return -1;

  if (pid == 0)
    {
      /* The child. */
      if (execv (args[0], MAYBE_TO_PTR32 (args)) != 0)
        _exit (1);
    }

  /* The parent.  */
  finished = waitpid (pid, &status, 0);

  if (finished != pid || WIFEXITED (status) == 0)
    return -1;

  return WEXITSTATUS (status);
}

Thanks for your help :).

Laurent



Reply via email to