tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Syscall kill(2) called for a zombie process should return 0



Hello,

I've found the following problem, and according to:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
(2nd last paragraph of rationale)

It seems like NetBSD should return 0 when killing a zombie process (as
FreeBSD and Linux do).

FreeBSD fixed this in 2004 with the following commit:

http://svnweb.freebsd.org/base?view=revision&revision=132856

Please review the attached patch.
Syscall kill(2) called for a zombie process should return 0.

From: Roger Pau Monne <roger.pau%citrix.com@localhost>

See:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
(2nd last paragraph of rationale)

FreeBSD fixed this in 2004 with the following commit:

http://svnweb.freebsd.org/base?view=revision&revision=132856
---
 sys/kern/sys_sig.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/sys/kern/sys_sig.c b/sys/kern/sys_sig.c
index 7261ad2..8ea8794 100644
--- a/sys/kern/sys_sig.c
+++ b/sys/kern/sys_sig.c
@@ -244,6 +244,15 @@ kill1(struct lwp *l, pid_t pid, ksiginfo_t *ksi, 
register_t *retval)
                mutex_enter(proc_lock);
                p = proc_find(pid);
                if (p == NULL) {
+                       /*
+                        * IEEE Std 1003.1-2001: return success
+                        * when killing a zombie.
+                        */
+                       p = proc_find_raw(pid);
+                       if (p != NULL && P_ZOMBIE(p)) {
+                               mutex_exit(proc_lock);
+                               return 0;
+                       }
                        mutex_exit(proc_lock);
                        return ESRCH;
                }


Home | Main Index | Thread Index | Old Index