zombie processes handled incorrectly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
This may or may not be related to an issue I reported in August[1] yet never filed as a bug.
I'm attaching a bit of sample code that spawns a process, sends it to sleep, has it continue, kills it, and then waits for it (waiting should immediately return because the process is dead).
Instead, this is the output I get:
Sending signal: +SIGSTOP+
Internal status now: STOPPED (expected: STOPPED)
External status now: [T] (expected: [T])
Sending signal: +SIGCONT+
Internal status now: RUNNING (expected: RUNNING)
External status now: [S] (expected: [S])
Sending signal: +SIGKILL+
Internal status now: RUNNING (expected: SIGNALED)
External status now: [Z] (expected: []/[Z])
Internal status now: RUNNING (expected: SIGNALED)
External status now: [Z] (expected: []/[Z])
If we're lucky, this will terminate at some point...
at which point the repl hangs and never returns. Apparently, waiting for a zombie is not a good idea. It's surprising that I end up with a zombie at all. Moreover, process-status should not be reporting its status as RUNNING. Here's the code (I wrote it such that ideally it would work on sbcl and ccl, for comparison. ccl is mostly okay[2] with it):
#+sbcl (require :sb-posix)
(defconstant +sigkill+
#+clozure (symbol-value (read-from-string "#$SIGKILL"))
#+sbcl sb-posix:sigkill)
(defconstant +sigstop+
#+clozure (symbol-value (read-from-string "#$SIGSTOP"))
#+sbcl sb-posix:sigstop)
(defconstant +sigcont+
#+clozure (symbol-value (read-from-string "#$SIGCONT"))
#+sbcl sb-posix:sigcont)
(defun check-internal-
(format t "Internal status now: ~a (expected: ~a)~%"
#+clozure (ccl:external-
#+sbcl (sb-ext:
(defun get-pid (process)
#+clozure (ccl::external-
#+sbcl (sb-ext:process-pid process))
(defun internal-
(format t "Sending signal: ~S~%" signal-symbol)
(let ((signal-value (symbol-value signal-symbol)))
#+clozure (ccl:signal-
#+sbcl (sb-ext:
(defun check-external-
(let ((pid (get-pid process))
(stream (make-string-
(let ((arg-list (list "ps" "-h" "-p" (format nil "~a" pid) "-o" "state")))
(funcall #+clozure #'ccl:run-program
(format t "External status now: [~a] (expected: ~a)~%"
(defun wait-for-process (process)
#+clozure (ccl::external-
#+sbcl (sb-ext:
(let ((p (funcall #+clozure #'ccl:run-program
(internal-
(sleep 3)
(check-
(check-
(internal-
(sleep 3)
(check-
(check-
(internal-
(sleep 3)
(check-
(check-
(sleep 10)
(check-
(check-
(format t "If we're lucky, this will terminate at some point...~%")
(wait-for-process p))
$ sbcl-git --version
SBCL 1.3.9.85-8f36709
$ uname -a
Linux fedora 4.7.0-x86_
$
* *features*
(:64-BIT :64-BIT-REGISTERS :ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS
:C-STACK-
:COMPLEX-
:FP-AND-
:INTEGER-EQL-VOP :LARGEFILE :LINKAGE-TABLE :LINUX :LITTLE-ENDIAN
:MEMORY-
:OS-PROVIDES-
:OS-PROVIDES-POLL :OS-PROVIDES-PUTWC :OS-PROVIDES-
:PACKAGE-
:READ-ONLY-TRAMPS :SB-DOC :SB-EVAL :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS
:SB-SIMD-PACK :SB-SOURCE-
:STACK-
:STACK-
:STACK-
:UNWIND-
[1] https:/
[2] http://
Changed in sbcl: | |
assignee: | nobody → Jan Moringen (scymtym) |
status: | New → In Progress |
Changed in sbcl: | |
status: | In Progress → Fix Committed |
assignee: | Jan Moringen (scymtym) → nobody |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |