English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Unix.system returns "no child processes"
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-09 (20:26)
From: Olivier Andrieu <oandrieu@n...>
Subject: Re: [Caml-list] Unix.system returns "no child processes"
> Christopher Conway wrote:
> I am using Unix.system to invoke external commands from within Ocaml. On
> the old machines (with the 32-bit version of Ocaml), I would
> occasionally get the exception Unix_error(ECHILD,"waitpid","") from
> Unix.system. With the new machines, I'm seeing this at every call to
> Unix.system, every time. I have investigate the behavior of the
> sub-processes, and they are terminating normally, with no indication of
> any error.

the linux manpage for waitpid has this:

       ECHILD if the process specified in pid does not exist or is not a
child of the calling process.  (This can
              happen  for  one’s  own child if the action for SIGCHLD is
set to SIG_IGN. See also the LINUX NOTES
              section about threads.)

This begs the question: did you setup the SIGCHLD handler to SIG_IGN ? or
are you using threads ?

> I have a theory why this is happening, but no supporting evidence. It
> goes like this: system is basically fork+execv+waitpid; on the new
> machines, fork+execv is terminating so quickly that the process is gone
> before the call to waitpid.

No, the process should stay as a zombie (unless you've set a signal
handler for SIGCHLD I guess)