From: mike Date: Wed, 18 May 2011 17:28:45 +0000 (+0000) Subject: The scheduler now sets the process group for child processes and manages the X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29335b68ea348e3aa4c0c0dc3fe9a2cc3af1f586;p=thirdparty%2Fcups.git The scheduler now sets the process group for child processes and manages the group (STR #2829) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9781 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index f7d609ecfe..bd806f8990 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,10 @@ -CHANGES.txt - 2011-05-11 +CHANGES.txt - 2011-05-18 ------------------------ CHANGES IN CUPS V1.5b1 + - The scheduler now sets the process group for child processes and + manages the group (STR #2829) - Fixed some minor issues discovered by a Coverity scan (STR #3838) - The scheduler now more carefully creates and removes configuration, cache, and state files (STR #3715) diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index 5fd9143dcb..511795de34 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -166,6 +166,9 @@ AC_CHECK_FUNCS(random lrand48 arc4random) dnl Check for geteuid function. AC_CHECK_FUNCS(geteuid) +dnl Check for setpgid function. +AC_CHECK_FUNCS(setpgid) + dnl Check for vsyslog function. AC_CHECK_FUNCS(vsyslog) diff --git a/config.h.in b/config.h.in index 20988405fb..13f6411fd3 100644 --- a/config.h.in +++ b/config.h.in @@ -231,6 +231,13 @@ #undef HAVE_GETEUID +/* + * Do we have the setpgid() function? + */ + +#undef HAVE_SETPGID + + /* * Do we have the vsyslog() function? */ diff --git a/scheduler/process.c b/scheduler/process.c index 5e4e9e7ed6..3d8247914b 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -246,9 +246,9 @@ cupsdEndProcess(int pid, /* I - Process ID */ if (!pid) return (0); else if (force) - return (kill(pid, SIGKILL)); + return (kill(-pid, SIGKILL)); else - return (kill(pid, SIGTERM)); + return (kill(-pid, SIGTERM)); } @@ -476,6 +476,19 @@ cupsdStartProcess( if (!root) nice(FilterNice); + /* + * Put this process in its own process group so that we can kill any child + * processes it creates. + */ + +#ifdef HAVE_SETPGID + if (setpgid(0, 0)) + exit(errno); +#else + if (setpgrp()) + exit(errno); +#endif /* HAVE_SETPGID */ + /* * Change user to something "safe"... */ diff --git a/vcnet/config.h b/vcnet/config.h index 7be500d366..e7405facc2 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -290,6 +290,13 @@ /* #undef HAVE_GETEUID */ +/* + * Do we have the setpgid() function? + */ + +/* #undef HAVE_SETPGID */ + + /* * Do we have the vsyslog() function? */ diff --git a/xcode/config.h b/xcode/config.h index fabfac8d1b..6e97a43a8d 100644 --- a/xcode/config.h +++ b/xcode/config.h @@ -229,6 +229,13 @@ #define HAVE_GETEUID 1 +/* + * Do we have the setpgid() function? + */ + +#define HAVE_SETPGID 1 + + /* * Do we have the vsyslog() function? */