mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	posix: added setpgrp() and, if sgi, setsid() and setpgid(pid, pgid)
This commit is contained in:
		
							parent
							
								
									1899c2e055
								
							
						
					
					
						commit
						c2670a000b
					
				
					 1 changed files with 59 additions and 1 deletions
				
			
		| 
						 | 
					@ -34,6 +34,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
				
			||||||
#define NO_UNAME
 | 
					#define NO_UNAME
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __sgi
 | 
				
			||||||
 | 
					#define DO_PG
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <setjmp.h>
 | 
					#include <setjmp.h>
 | 
				
			||||||
| 
						 | 
					@ -636,6 +640,23 @@ posix_getpgrp(self, args)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static object *
 | 
				
			||||||
 | 
					posix_setpgrp(self, args)
 | 
				
			||||||
 | 
						object *self;
 | 
				
			||||||
 | 
						object *args;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!getnoarg(args))
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					#ifdef SYSV
 | 
				
			||||||
 | 
						if (setpgrp() < 0)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						if (setpgrp(0, 0) < 0)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							return err_errno(PosixError);
 | 
				
			||||||
 | 
						INCREF(None);
 | 
				
			||||||
 | 
						return None;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static object *
 | 
					static object *
 | 
				
			||||||
posix_getppid(self, args)
 | 
					posix_getppid(self, args)
 | 
				
			||||||
	object *self;
 | 
						object *self;
 | 
				
			||||||
| 
						 | 
					@ -815,7 +836,38 @@ posix_times(self, args)
 | 
				
			||||||
	return tuple;
 | 
						return tuple;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif /* DO_TIMES */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DO_PG
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static object *
 | 
				
			||||||
 | 
					posix_setsid(self, args)
 | 
				
			||||||
 | 
						object *self;
 | 
				
			||||||
 | 
						object *args;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!getnoarg(args))
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						if (setsid() < 0)
 | 
				
			||||||
 | 
							err_errno(PosixError);
 | 
				
			||||||
 | 
						INCREF(None);
 | 
				
			||||||
 | 
						return None;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static object *
 | 
				
			||||||
 | 
					posix_setpgid(self, args)
 | 
				
			||||||
 | 
						object *self;
 | 
				
			||||||
 | 
						object *args;
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int pid, pgrp;
 | 
				
			||||||
 | 
						if (!getargs(args, "(ii)", &pid, &pgrp))
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						if (setpgid(pid, pgrp) < 0)
 | 
				
			||||||
 | 
							err_errno(PosixError);
 | 
				
			||||||
 | 
						INCREF(None);
 | 
				
			||||||
 | 
						return None;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* DO_PG */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct methodlist posix_methods[] = {
 | 
					static struct methodlist posix_methods[] = {
 | 
				
			||||||
| 
						 | 
					@ -859,10 +911,16 @@ static struct methodlist posix_methods[] = {
 | 
				
			||||||
	{"getuid",	posix_getuid},
 | 
						{"getuid",	posix_getuid},
 | 
				
			||||||
	{"kill",	posix_kill},
 | 
						{"kill",	posix_kill},
 | 
				
			||||||
	{"popen",	posix_popen},
 | 
						{"popen",	posix_popen},
 | 
				
			||||||
 | 
						{"setpgrp",	posix_setpgrp},
 | 
				
			||||||
	{"wait",	posix_wait},
 | 
						{"wait",	posix_wait},
 | 
				
			||||||
	{"waitpid",	posix_waitpid},
 | 
						{"waitpid",	posix_waitpid},
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DO_PG
 | 
				
			||||||
 | 
						{"setsid",	posix_setsid},
 | 
				
			||||||
 | 
						{"setpgid",	posix_setpgid},
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{NULL,		NULL}		 /* Sentinel */
 | 
						{NULL,		NULL}		 /* Sentinel */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue