Version française
Home     About     Download     Resources     Contact us    
Browse thread
Unix.waitpid
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Oliver Bandel <oliver@f...>
Subject: Re: [Caml-list] Unix.waitpid
On Thu, Jun 30, 2005 at 02:09:51PM +0200, Bauer, Christoph wrote:
> Hi,
> 
> my app should wait for some processes. This is done 
> by my function wait, which gets a pid, a idle function (e.g. ignore)
> + its value and a delay time between polling:
> 
> 
> let delay s = ignore (Unix.select [] [] [] s)
> 
> let wait ?(delay_time = 0.01) pid idle x =
>   let rec wait' () =
>     idle x;
>     delay delay_time;
>     let pid = try fst (Unix.waitpid [Unix.WNOHANG] pid) with _  -> 1 in
>       if pid <> 0 then wait' ()
>   in wait' ()

Does you have a valid pid (as calling parameter)?
You may better use 0 or -1 in the call to Unix.waitpid.

Maybe WUNTRACED would also makes sense as flag.
Maybe better not testing with "_" in try-with.


P.S.: Documentation could be better.
I had to look in the C-API manpage to know what parameters
the Unix.aitpid awaits.
That the one arg is the pid is mentioned in the documentation, but there
is no function call example, to identify the second arg as the wpid.


Ciao,
   Oliver Bandel