Charles.Forsyth2008010978a844018 years agoHistory
100 lines · 1.9 KB · Text
RawDownload
.TH WAIT 2.SH NAMEwait \- wait for child process to exit.SH SYNOPSIS.EXwait := load Wait Wait->PATH; Wait: module{   init:    fn();   read:    fn(fd: ref Sys->FD): (int, string, string);   monitor: fn(fd: ref Sys->FD): (int, chan of (int, string, string));   parse:   fn(status: string): (int, string, string);};.EE.SH DESCRIPTION.B Waithelps use the.B waitfile of.IR prog (3)..PP.B Initmust be called to initialise the module before invoking any other function..PP.B Readreads a single wait record from file descriptor.IR fd ,which must be open on some process.IR p 's.B waitfile,and returns a tuple.BI ( pid\f5,\fP\ module\f5,\fP\ status )where.I pidis the process ID of a child of.I pthat has exited,.I moduleis the name of the module that caused.I pto exit,and.I statusis nil if.I pidended without error or a status message otherwise.If reading the.B waitfile resulted in end of file or error,.I pidis 0 (for end of file) or.B -1on error (and.I statusis the system error string for the error)..PP.B Monitorprovides a channel interface to the.B waitfile open on.IR fd ;it allows, for instance,a process to use.B altto exchange data with a process but also see it exit (for good or ill).It starts a monitor process that applies.B readto.I fdand sends each resulting tuple on a channel.It returns a tuple.BI ( pid\f5,\fP\ c )where.I pidis the process ID of the monitor process (which can be used to kill it when done with it),and.I cis the channel on which the process sends each value it reads.The tuple has the format described above for.BR read .The monitor process exits when the wait file.I fdyields end of file or error, after sending the corresponding tuple on.IR c ..PP.B Parsetakes a complete.I statusstring as read from a.B waitfile and returns a tuple.BI ( pid\f5,\fP\ module\f5,\fP\ status )as described for.B readabove..SH SEE ALSO.IR sh (1),.IR prog (3)