Commit Graph

98 Commits

Author SHA1 Message Date
Brad King b9e3c243d4 KWSys: Teach Process to error on empty command
Do not try to execute a child with no command line.  Previously this led
to a silent hang.
2010-06-11 11:00:38 -04:00
Brad King 60478de3e5 KWSys: Process tree kill for Solaris 2010-06-11 10:15:19 -04:00
Brad King 83d3b1e427 KWSys: Process tree kill for kFreeBSD, GNU/Hurd
kFreeBSD and Hurd have the same userland as Linux.  This change is
necessary to enable kwsysProcessKill() to kill child processes on
kFreeBSD.  The bug was detected by CTestTestTimeout test.

Patch from "Modestas Vainius <modestas@vainius.eu>".
See issue #10432.
2010-05-11 13:34:54 -04:00
Brad King 60de059bff KWSys Process: Add OpenBSD process tree kill support
Patch from Chuck Atkins <chuck.atkins@kitware.com>
2010-04-19 16:30:37 -04:00
Brad King 1560d9dcca KWSys: Enable process tree killing on kFreeBSD
Teach kwsysProcessKill to identify processes on this platform using the "ps"
command just as on Linux.  Patch from Modestas Vainius <modax@debian.org>.
See issue #10432.
2010-03-18 08:43:05 -04:00
Brad King 8d0161c8ff Trust umask for file permissions
Open output files with mode 0666 so that permissions are not more strict
than umask permits.  See issue #10126.
2010-01-12 11:57:01 -05:00
Brad King 1a5f209e62 KWSys: List processes with "ps -ef" on OpenSolaris
In order to kill process trees we need to list all processes to find
those whose parent we are killing.  We implement process listing on
OpenSolaris by using "ps -ef" and parsing the resulting format:

     UID   PID  PPID   C    STIME TTY         TIME CMD
     %*s    %d    %d   %*[^\n]\n
2009-12-01 08:37:14 -05:00
Brad King be36c14bea KWSys: Use "ps -Af" for process list on QNX
In order to kill process trees we need to list all processes to find
those whose parent we are killing.  We implement process listing on QNX
using "ps -Af" and parsing the resulting format:

  UID        PID       PPID  C STIME TTY          TIME CMD
  %*d         %d         %d  %*[^\n]\n
2009-12-01 08:10:22 -05:00
Brad King b21f1eaeae KWSys: Restore SIGSTOP/SIGKILL to end process tree
On UNIX systems we kill a tree of processes by performing a DFS walk of
the tree.  We send SIGSTOP to each process encountered, recursively
handle its children, and then send SIGKILL.

We once used the above approach in the past, but it was removed by the
commit "Do not send both SIGSTOP and SIGKILL when killing a process".
The commit was meant to work-around an OS X 10.3 bug in which the child
would not always honor SIGKILL after SIGSTOP.  At the time we wrongly
assumed that the process tree remains intact after SIGKILL and before
the child is reaped.  In fact the grandchildren may be re-parented to
ppid=1 even before the child is reaped, which causes the DFS walk to
miss them.
2009-11-30 13:14:02 -05:00
Alexander Neundorf 5e2851f855 fix two more icpc warnings, ok by Brad (float compared for equality, unused variable)
Alex
2009-10-19 12:57:36 -04:00
Brad King de955e4b6d Convert KWSys to OSI-approved BSD License
This converts the KWSys license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the KWSys copyright to
cover the full development time range.
2009-09-28 11:37:35 -04:00
Brad King 18e639d48a ENH: Provide unix-sytle command line parsing
Add System_Parse_CommandForUnix to the KWSys System interface as a
utility to parse a unix-style command line.  Move the existing
implementation out of ProcessUNIX.  Add a flags argument reserved for
future use in providing additional behavior.
2009-07-13 16:22:14 -04:00
Brad King 219626a2be COMP: Do not compile VMS-specific code on non-VMS
This helps avoid fixing VMS-specific code for non-VMS compilers where it
isn't needed anyway.
2009-06-12 15:44:50 -04:00
Francois Bertel 17daa9398a COMP:Fixed warning with gcc 4.3.3: passing argument 1 of kwsysProcessSetVMSFeature discards qualifiers from pointer target type. 2009-06-12 13:33:35 -04:00
Brad King 312ca9670f ENH: Teach KWSys Process basic VMS support
This achieves basic process execution on OpenVMS.  We use work-arounds
for different fork()/exec() behavior and a lack of select().

VMS emulates fork/exec using setjmp/longjmp to evaluate the child and
parent return cases from fork.  Therefore both must be invoked from the
same function.

Since select() works only for sockets we use the BeOS-style polling
implementation.  However, non-blocking reads on empty pipes cannot be
distinguished easily from the last read on a closed pipe.  Therefore we
identify end of data by an empty read after the child terminates.
2009-06-10 11:48:34 -04:00
Brad King 1eec4fe6ad BUG: Fix non-select process impl without timeout
This avoids use of an uninitialized value in the KWSys ProcessUNIX
polling implementation when no timeout is given.
2009-06-10 11:46:21 -04:00
Bill Hoffman 7fc99c94d4 ENH: check in almost building VMS stuff with VMSBuild directory since the bootstrap script will not work on VMS 2009-04-23 11:09:47 -04:00
Francois Bertel 257937f2bd COMP:Try to fix compile error with qnx gcc. 2009-03-16 17:38:17 -04:00
Francois Bertel d0b32b42a1 COMP:Fixed gcc 4.3.2 warning with -O1 and above: ignoring return value of read'), declared with attribute warn_unused_result 2009-03-16 17:13:14 -04:00
Francois Bertel 7b9b56d80e COMP:Fixed warnings. 2009-03-16 15:02:25 -04:00
Francois Bertel ef36d72c89 COMP:Fixed warnings. 2008-12-15 17:19:26 -05:00
Bill Hoffman 67dc176ffa ENH: a few more haiku fixes, stop the debugger from coming up for tests 2008-09-22 14:05:13 -04:00
Bill Hoffman 64fc597de2 ENH: add initial support for HAIKU OS from bug# 7425 2008-09-15 17:53:28 -04:00
Brad King 07665de038 BUG: Handle case when select() lies
According to "man select" on Linux it is possible that select() lies
about data being ready on a pipe in some subtle cases.  We deal with
this by switching to non-blocking i/o and checking for EAGAIN.  See
issue #7180.
2008-08-20 09:57:09 -04:00
Mathieu Malaterre 7499bb250d ENH: all ctype function have the same issue: char can be signed or unsigned, since isspace only deal with >=0 value (except EOF) one has to first cast it to unsigned char 2008-05-13 05:18:51 -04:00
Bill Lorensen 614b1ab358 COMP: warning, isprint and isspace take int args. 2008-05-12 12:01:09 -04:00
Mathieu Malaterre f410daffec STYLE: minor comments 2008-04-02 08:36:51 -04:00
Brad King 1c2ffbb5bc BUG: Fix hang in Process_Kill on OS X caused by an OS bug in which a pipe read end cannot be closed if the pipe write end is open, the pipe is full, and another process is blocking waiting to write. Work around the problem by killing the children before closing the pipes. 2008-01-10 18:32:38 -05:00
Brad King 9dec9a0c3b COMP: Fix for platforms that do not have siginfo on their signal handlers. 2007-06-27 11:39:16 -04:00
Brad King 01c7db07c3 BUG: Do not send both SIGSTOP and SIGKILL when killing a process. The SIGSTOP seems to be able to block the SIGKILL occasionally. Also the SIGKILL is sufficient since the process table entry will still exist until it is reaped with waitpid. 2007-05-16 13:10:45 -04:00
Brad King aa4d7847ee COMP: Fix code-not-reached warnings for SunCC. 2007-05-03 13:03:13 -04:00
Bill Hoffman 6b7bf34341 COMP: remove warning 2006-12-05 09:02:32 -05:00
Bill Hoffman 1513773310 ENH: fix build error on IRIX 2006-12-05 08:39:22 -05:00
Brad King de8ffcaef4 ENH: Changes based on patch from Ryan C. Gordon to enable process execution on BeOS. There seems to be no way to implement it without polling (or threads). 2006-12-04 14:42:47 -05:00
Brad King 40adb2ce03 ENH: Adding tests KWSYS_C_HAS_PTRDIFF_T and KWSYS_C_HAS_SSIZE_T to help ProcessUNIX.c build everywhere without warnings. 2006-10-04 17:27:17 -04:00
Brad King 48ee381e6b BUG: Need to initialize to not use native pipes. 2006-10-03 10:26:32 -04:00
Brad King 6eef6638a5 ENH: Added Process_SetPipeNative method to allow user code to override the pipes connected to the child pipeline. 2006-10-03 09:10:03 -04:00
Brad King 9b2b2b5f1b COMP: Use SA_RESTART only if it is defined for the current platform. This partially addresses bug#3556. 2006-08-01 14:28:03 -04:00
Brad King 6438bec4c9 ENH: Added Option_Verbatim to run whole command lines directly. 2006-06-15 14:40:42 -04:00
Brad King 9b74e597be BUG: Do not leak global table of processes. 2006-05-24 10:13:18 -04:00
Brad King 35334d01cd ENH: Re-enabling SIGCHLD handling implementation with a fix for Cygwin. 2006-05-23 11:48:15 -04:00
Brad King 29b75dda97 BUG: Reverting previous change until it can be fixed on Cygwin. 2006-05-22 15:11:42 -04:00
Brad King 0d594a4538 ENH: Implemented handling of SIGCHLD to detect the termination of immediate children. This allows grandchildren to remain running after the children exit. 2006-05-21 10:26:28 -04:00
Brad King 3dd70af5a0 ENH: Enabling process tree killing on Cygwin. 2006-05-20 18:50:27 -04:00
Brad King bde71e9668 ENH: Enabled process tree killing on AIX. 2006-03-08 13:06:46 -05:00
Brad King 6fb7bac013 ENH: Enabled process tree killing on the SGI. 2006-03-08 12:42:59 -05:00
Brad King 95f86d5d6f ENH: Enabled process tree killing for FreeBSD and Sun. 2006-03-08 12:36:14 -05:00
Brad King 17d79233ff ENH: Enabled process tree killing on HP-UX. 2006-03-08 12:12:37 -05:00
Brad King c31c18bb9c BUG: Do not leak ps FILE when the process starts but reading the header fails. 2006-03-08 11:57:41 -05:00
Brad King 3c39accee9 ENH: Added implementation of process tree killing that runs "ps" to traverse the tree. 2006-03-08 11:38:51 -05:00