ENH: Enabled process tree killing for FreeBSD and Sun.

This commit is contained in:
Brad King 2006-03-08 12:36:14 -05:00
parent 17d79233ff
commit 95f86d5d6f

View File

@ -1899,15 +1899,14 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* For systems without the /proc filesystem we try to obtain process /* We try to obtain process information by invoking the ps command.
information by invoking the ps command. Here we define the command Here we define the command to call on each platform and the
to call on each platform and the corresponding parsing format corresponding parsing format string. The parsing format should
string. The parsing format should have two integers to store: the have two integers to store: the pid and then the ppid. */
pid and then the ppid. */ #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__APPLE__)
# define KWSYSPE_PS_COMMAND "ps axo pid,ppid" # define KWSYSPE_PS_COMMAND "ps axo pid,ppid"
# define KWSYSPE_PS_FORMAT "%d %d\n" # define KWSYSPE_PS_FORMAT "%d %d\n"
#elif defined(__hpux) #elif defined(__hpux) || defined(__sparc)
# define KWSYSPE_PS_COMMAND "ps -ef" # define KWSYSPE_PS_COMMAND "ps -ef"
# define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n" # define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n"
#endif #endif
@ -1920,8 +1919,9 @@ static void kwsysProcessKill(pid_t process_id)
/* Suspend the process to be sure it will not create more children. */ /* Suspend the process to be sure it will not create more children. */
kill(process_id, SIGSTOP); kill(process_id, SIGSTOP);
/* Kill all children if we can find them. First try using the /proc /* Kill all children if we can find them. */
filesystem. */ #if defined(__linux__)
/* First try using the /proc filesystem. */
if((procdir = opendir("/proc")) != NULL) if((procdir = opendir("/proc")) != NULL)
{ {
#if defined(MAXPATHLEN) #if defined(MAXPATHLEN)
@ -1976,8 +1976,9 @@ static void kwsysProcessKill(pid_t process_id)
} }
closedir(procdir); closedir(procdir);
} }
#if defined(KWSYSPE_PS_COMMAND)
else else
#endif
#if defined(KWSYSPE_PS_COMMAND)
{ {
/* Try running "ps" to get the process information. */ /* Try running "ps" to get the process information. */
FILE* ps = popen(KWSYSPE_PS_COMMAND, "r"); FILE* ps = popen(KWSYSPE_PS_COMMAND, "r");