contents   index   previous   next



Unix.waitpid()

syntax:

Unix.waitpid(pid, status, flags)

where:

pid - child process interested in or -1 for any.

 

status - status of the process.

 

flags - WNOHANG or 0.

 

return:

number - process id of the exiting child, else -1 for error.

 

description:

Very similar to Unix.wait(), except you can specify which child process you care about as well as some flags. The only flag currently given a name is WNOHANG, which means that if no child is ready to exit, the call returns immediately. Unix gurus who need the full functionality can put the other possible flag values here.

 

see:

Unix.kill(), Unix.waitpid()

 

example:

// This function is most useful in the main loop

// of a server daemon

// (see inn.jse, unix/daemon.jse samples.)

// By calling it each time through the loop such as:

 

Unix.waitpid(-1,var status, WNOHANG);

 

// Child processes will get cleaned up and

// zombie processes will not stick around

// wasting resources.