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
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-30 (12:09)
From: Bauer, Christoph <Christoph.Bauer@l...>
Subject: Unix.waitpid

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' ()

It works mostly, but in some rare, non-deterministic cases wait loops
In a seconds round it works without problems. I saw this behaviour on Linux
and Windows. Can anybody help me?


Christoph Bauer
Dipl. Inf.

LMS Deutschland GmbH
Luxemburgerstr. 7
D-67657 Kaiserslautern

T +49 631 303 22 152