[M3devel] waitpid contortions

Tony Hosking hosking at cs.purdue.edu
Mon Jan 12 05:27:07 CET 2009


Jay,

To avoid your contortions surrounding usage of waitpid in sysutils, I  
propose the following.

Implement ThreadPosix.WaitProcess as a thing wrapper over waitpid:

PROCEDURE WaitProcess (pid: int; VAR status: int): int =
   (* ThreadPThread.m3 and ThreadPosix.m3 are very similar. *)
   BEGIN
     LOOP
       WITH r = Uexec.waitpid(pid, ADR(status), 0) DO
         <*ASSERT r # 0*>
         IF r > 0 THEN RETURN r END;
         IF Cerrno.GetErrno() # Uerror.EINTR THEN RETURN r END;
       END;
     END;
   END WaitProcess;

Implement Process.Wait as it used to be originally, calling  
SchedulerPosix.WaitProcess instead of waitpid.
Implement SystemPosix.Wait using SchedulerPosix.Wait to throw  
exceptions as defined in the original code.

Antony Hosking | Associate Professor | Computer Science | Purdue  
University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090112/c24aa1af/attachment-0001.html>


More information about the M3devel mailing list