pxfwait

Date:

10-20-2011

NAME

PXFWAIT, PXFWAITPID - Obtains information about a calling process’ child process

SYNOPSIS

INTEGER istat, iretpid, error
CALL PXFWAIT(istat, iretpid, ierror)

INTEGER ipid, istat, ioptions, iretpid, ierror
CALL PXFWAITPID(ipid, istat, ioptions, iretpid, ierror)

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION

The PXFWAIT routine uses the wait(2) system call to obtain information about one of the calling process’s child processes.

The PXFWAITPID routine uses the waitpid(2) system call to obtain information about one of the calling process’s child processes.

All arguments must be of default kind unless documented otherwise. Default kind is KIND=4 for integer, real, complex, and logical arguments.

The following is a list of arguments for this routine:

ipid

An input integer variable containing the child process ID for which information is requested.

  • If ipid is equal to -1, status is requested for any child process; PXFWAITPID is then equivalent to PXFWAIT.

  • If ipid is greater than 0, it specifies the process ID of a single child process for which status is requested.

  • If ipid is equal to 0, status is requested for any child process with a process group ID that is equal to that of the calling process.

  • If ipid is less than -1, status is requested for any child process with a process group ID that is equal to the absolute value of ipid.

istat

An output integer variable for the status information.

ioptions

An input integer variable constructed from an inclusive OR of zero or more of the following options:

WNOHANG

The waitpid system call does not suspend execution of the calling process if status is not immediately available for one of the calling processes specified by pid.

WUNTRACED

If job control is supported, the status of any child processes specified by pid that are stopped, and with a status that has not yet been reported since they stopped, are also reported to the requesting process.

iretpid

An output integer variable for the child process ID.

ierror

An output integer variable that contains zero if the routine was successful or nonzero if the routine was not successful.

Any of the following error values may be returned:

ECHILD

PXFWAIT: If the calling process has no existing unwaited-for child processes. PXFWAITPID: The process or process group specified by ipid does not exist or is not a child of the calling process.

EINTR

If receipt of a signal other than the death-of-a-child-process signal.

EINVAL

The value of the ioptions argument is not valid.

EXAMPLES

Example 1: PXFWAIT example

program pxftest
integer istat, iretpid, ipid, ierror, i, j
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
    print *,'FAILED: PXFFORK call failed with error = ',ierror
else
    if (ipid .eq. 0) then
       j = 0
       do i=1,100000
          j = j + i
       enddo
       stop
    else
       CALL PXFWAIT(istat,iretpid,ierror)
       if (ierror .eq. 0) then
           print *,'PASSED: PXFWAIT normal test'
       else
           print *,'FAILED: PXFWAIT call with error = ',ierror
       endif
    endif
endif
end

Example 2: PXFWAITPID example

program pxftest
integer istat, iretpid, ipid, ierror, i, j, ioptions
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
   print *,'FAILED: PXFFORK call failed with error = ',ierror
else
   if (ipid .eq. 0) then
      j = 0
      do i=1,100000
         j = j + i
      enddo
      stop
   else
      ioptions = 0
      CALL PXFWAITPID(ipid,istat,ioptions,iretpid,ierror)
      if (ierror .eq. 0) then
         print *,'PASSED: PXFWAITPID normal test'
      else
         print *,'FAILED: PXFWAITPID call with error = ',ierror
      endif
   endif
endif
end

SEE ALSO

wait(2), waitpid(2)