Sun Studio 12: Fortran Library Reference

1.4.54 wait: Wait for a Process to Terminate

The function is:

INTEGER*4 wait

n = wait( status )

status

INTEGER*4

Output 

Termination status of the child process 

Return value 

INTEGER*4

Output 

n>0: Process ID of the child process

n<0: n=System error code; see wait(2).

wait suspends the caller until a signal is received, or one of its child processes terminates. If any child has terminated since the last wait, return is immediate. If there are no children, return is immediate with an error code.

Example: Code fragment using wait():


       INTEGER*4 n, status, wait
       …
       n = wait( status )
       if ( n .lt. 0 ) stop ’wait: error’
       …
       end

See also: wait(2), signal(3F), kill(3F), and perror(3F).