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/pxfsetpgid.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 /* PXFSETPGID -- Set Process Group ID for Job Control 00046 * (section 4.3.3 of Posix 1003.9-1992) 00047 * 00048 * Synopsis: 00049 * 00050 * SUBROUTINE PXFSETPGID(IPID, IPGID, IERROR) 00051 * INTEGER IPID, IPGID, IERROR 00052 * 00053 * 00054 * Function Description: 00055 * The routine PXFSETPGID uses the setpgid(2) system call to change the 00056 * process group ID of the process with process ID IPID. The process group 00057 * ID may be for an existing process group or a new process group which will 00058 * be created. Upon sucessful completion, the process with process ID IPID 00059 * will have its process group ID set to IPGID. 00060 * 00061 * Description of Arguments: 00062 * 00063 * IPID is an input integer variable. IPID contains the process ID of the 00064 * process to change the process group ID. As a special case, if IPID 00065 * is zero the process ID of the calling process is used. 00066 * 00067 * IPGID is an input integer variable containing the new process group ID. 00068 * 00069 * IERROR is an output integer variable that will contain 00070 * the status: 00071 * 00072 * zero - PXFSETPGID was successful. 00073 * 00074 * nonzero - PXFSETPGID was not successful. 00075 * 00076 * PXFSETPGID may return any of the following error values: 00077 * 00078 * EACCES If the value of IPID matches the process ID of a child 00079 * process of the calling process and the child 00080 * process has successfully executed one of the 00081 * PXFEXEC(3F) functions. 00082 * 00083 * EINVAL If the value of IPGID is less than 0 or is not a value 00084 * supported by the implementation. 00085 * 00086 * EPERM If the process indicated by IPID is a session leader. 00087 * If the value of IPID is valid but matches the process 00088 * ID of a child process of the calling process and 00089 * the child process is not in the same session as 00090 * the calling process. 00091 * If the value of IPGID does not 00092 * match the process ID of the process indicated by 00093 * pid and no process with a process group ID exists 00094 * that matches the value of IPGID in the same session 00095 * as the calling process. 00096 * 00097 * ESRCH The value of IPID does not match the ID of the 00098 * calling process or of a child of the calling process. 00099 * 00100 */ 00101 00102 #ifdef _UNICOS 00103 void 00104 PXFSETPGID( 00105 #else 00106 void 00107 _PXFSETPGID( 00108 #endif 00109 _f_int *IPID, 00110 _f_int *IPGID, 00111 _f_int *IERROR 00112 ) 00113 { 00114 pid_t cipid, cipgid; 00115 00116 cipid = *IPID; 00117 cipgid = *IPGID; 00118 00119 if (setpgid(cipid, cipgid) == -1) { 00120 *IERROR = errno; 00121 return; 00122 } 00123 00124 *IERROR = 0; 00125 } 00126 00127 #ifndef _UNICOS 00128 void 00129 pxfsetpgid_( 00130 _f_int *IPID, 00131 _f_int *IPGID, 00132 _f_int *IERROR 00133 ) 00134 { 00135 _PXFSETPGID(IPID, IPGID, IERROR); 00136 } 00137 #endif
1.5.6