Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: [Caml-list] 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-10 (00:15)
From: Harrison, John R <johnh@i...>
Subject: RE: [Caml-list] Unix.system returns "no child processes"
Hi Chris,

| I am using Unix.system to invoke external commands from within Ocaml.
| 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
| any error.

I also sometimes see the intermittent error:

   Exception: Unix.Unix_error (Unix.ECHILD, "waitpid", "").

But what I'm doing with the system call is sufficiently sleazy that I
probably deserve it. I'm running OCaml under the checkpointing program
"ckpt". The following function is supposed to make the session
checkpoint itself, then print a startup banner when execution is

  let self_destruct bannerstring =
    let complete_banner =
      if bannerstring = "" then startup_banner
      else startup_banner^"\n        "^bannerstring in
    let pid = string_of_int(Unix.getpid()) in
     (ignore(Unix.system("kill -USR1 "^pid));
      Format.print_string complete_banner;
      Format.print_newline(); Format.print_newline());;

Sometimes I get the exception above instead of the banner when the
process restarts. The likelihood of that happening seems highly
machine-dependent, and even on a given machine there's no obvious