pxffork

Date:

10-20-2011

NAME

PXFFORK - Creates a process

SYNOPSIS

SUBROUTINE PXFFORK(ipid, ierror)

INTEGER ipid, ierror

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION

The PXFFORK routine uses the fork(2) system call to create a new process. The child process is the same as the parent process except for the following:

  • The child process has a unique, currently unused process ID.

  • The child process has a different parent process ID. The child process’s process ID is the parent process, or calling process, ID.

  • The child process has its own copy of the parent’s file descriptors. Each of the child’s file descriptors shares a common file pointer with the corresponding file descriptor of the parent process.

  • Process locks are not inherited by the child process (see plock(2)).

  • The utime, stime, cutime, and cstime of the child process are set to 0. The time left until an alarm clock signal is reset to 0.

  • All semadj values are cleared (see semop).

  • The parent’s set of pending signals are not inherited by the child.

UNICOS/mp only:

  • Record locks set by the parent process are not inherited by the child process (see fcntl(2) and lockf(3C)).

  • In a multitasking group, only the process that executed the fork system call is copied.

  • File locks previously set by the parent are not inherited by the child (see fcntl(2)).

  • The time left until an itimer signal is reset to 0.

  • The child will not inherit the ability to make graphics calls. The child process may receive a segmentation fault upon attempting to make a graphics call, unless it initializes itself as a graphics process via winopen() or ginit(). Currently, if the parent is a graphics process, the child’s attempt to become a graphics process will fail.

  • The share mask is set to 0 (see pthreads).

When using the Cray Fortran compiler, all arguments must be of default kind unless documented otherwise. The default kind is KIND=4 for integer, real, complex, and logical arguments.

The following is a list of arguments for this routine:

ipid

An output integer variable. ipid will be zero for the child process and the process ID of the child for the parent process.

ierror

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

The PXFFORK routine may return any of the following error values:

EAGAIN

If the system-imposed limit on the total number of processes under execution in the whole system (NPROC) is exceeded or if the system-imposed limit on the total number of processes under execution by one user (CHILD_MAX) is exceeded.

UNICOS/mp only:

EBUSY

If you attempt to enable accounting when it is already enabled, or if you issue a restart() attempt when another job or process in the system is using the jid or any pid associated with the job (or process) to be restarted.

EINTR

If an asynchronous signal (such as interrupt or quit), which you have elected to catch, occurred during a fork system call. When execution resumed after processing the signal, the interrupted system call returned this error condition.

ENOEXEC

If a request was made to execute a file that, although it has the appropriate permissions, does not start with a valid magic number (see a.out).

ENOMEM

If during an exec(2) or sbreak(2) system call, a program requested more space than the system could supply. This is not a temporary condition; the maximum space specification is a system parameter.

EAGAIN

If the amount of system memory required is temporarily unavailable.

ENOSPC

If the caller is a member of a share group and the total number of share group members plus child processes exceeds the maximum number of users specified by the usconfig() command (8 by default). Any changes made with usconfig (3P) must be done before the first sproc is formed.

ENOLCK

There are not enough file locks in the system.

EXAMPLES

program pxftest
integer ipid, ierror
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
   print *,'child'
else
   print *,'parent'
endif
end

SEE ALSO

exec(2), fcntl(2), fork(2), plock(2), restart(2), semop(2), ssbreak(2), shradmin(2)