pxfsetsid
- Date:
10-20-2011
NAME
PXFSETSID - Creates a new session for a calling process
SYNOPSIS
INTEGER isid, ierror
CALL PXFSETSID(isid, ierror)
IMPLEMENTATION
Cray Linux Environment (CLE)
DESCRIPTION
The PXFSETSID routine uses the setsid(2) system call to create a new session for the calling process. The calling process must not be the process leader for PXFSETSID to be successful.
After the successful completion of PXFSETSID, the calling process will be the session leader for the new session and the process group leader for the new process group. The calling process also will have no controlling terminal.
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:
- isid
An output integer variable for the new process group ID of the calling process.
- ierror
An output integer variable that contains zero if PXFSETSID was successful or nonzero if PXFSETSID was not successful.
This routine may return the EPERM error value if the calling process is already a process group leader, or the calling process group ID of a process other than the calling process matches the process ID of the calling process.
EXAMPLES
In this example, PXFFORK is called to create a child process, which calls PXFSETSID to create a new session. The child writes the value of ierror to Fortran unit 10 and stops. After the fork, the parent process waits for the child to finish execution, and then reads from Fortran unit 10. If the value read in from unit 10 is not equal to zero, the child’s call to PXFSETSID was unsucessful.
program pxftest
integer isid, iretpid, istat, ierror, i
CALL PXFFORK(iretpid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (iretpid .eq. 0) then
CALL PXFSETSID(isid, ierror)
write (10,*) ierror
stop
else
CALL PXFWAIT(istat, iretpid, ierror)
read (10,*) i
if (i .eq. 0) then
print *,'PASSED: PXFSETSID call under normal conditions'
else
print *,'FAILED: PXFSETSID call with error = ',i
endif
endif
endif
SEE ALSO
setsid(2), PXFFORK(3F)