00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #pragma ident "@(#) libf/pxf/pxfsetsid.c 92.1 06/29/99 11:36:06" 00038 00039 #include <errno.h> 00040 #include <liberrno.h> 00041 #include <fortran.h> 00042 #include <sys/types.h> 00043 #include <unistd.h> 00044 00045 /* PXFSETSID -- create session and set process group ID 00046 * (section 4.3.2 of Posix 1003.9-1992) 00047 * 00048 * Synopsis: 00049 * 00050 * SUBROUTINE PXFSETSID(ISID, IERROR) 00051 * INTEGER ISID, IERROR 00052 * 00053 * Function description: 00054 * The routine PXFSETSID uses the setsid(2) system call to create 00055 * new session for the calling process. The calling process must 00056 * not be the process leader for PXFSETSID to be successful. 00057 * 00058 * After the successful completion of PXFSETSID, the calling 00059 * process will be the session leader for the new session and the 00060 * process group leader for the new process group. The calling 00061 * process also will have no controlling terminal. 00062 * 00063 * Function arguments: 00064 * 00065 * ISID is an output integer variable for the new process 00066 * group ID of the calling process. 00067 * 00068 * IERROR is an output integer variable that will contain 00069 * the status: 00070 * 00071 * zero - PXFSETSID was successful. 00072 * 00073 * nonzero - PXFSETSID was not successful. 00074 * 00075 * PXFSETSID may return any of the following error values: 00076 * 00077 * EPERM If the calling process is already a process group 00078 * leader, or the calling process group ID of a 00079 * process other than the calling process 00080 * matches the process ID of the calling process. 00081 * 00082 * 00083 * 00084 */ 00085 00086 #ifdef _UNICOS 00087 void 00088 PXFSETSID( 00089 #else 00090 void 00091 _PXFSETSID( 00092 #endif 00093 _f_int *ISID, 00094 _f_int *IERROR 00095 ) 00096 { 00097 pid_t cisid; 00098 00099 if ((cisid = setsid()) == -1) { 00100 *IERROR = errno; 00101 return; 00102 } 00103 00104 *ISID = cisid; 00105 *IERROR = 0; 00106 } 00107 00108 00109 #ifndef _UNICOS 00110 void 00111 pxfsetsid_( 00112 _f_int *ISID, 00113 _f_int *IERROR 00114 ) 00115 { 00116 _PXFSETSID(ISID, IERROR); 00117 } 00118 #endif
1.5.6