From: Tanaka Akira <akr@m17n.org>
To: zsh-workers@sunsite.auc.dk
Subject: Re: fg/bg on FreeBSD.
Date: 07 May 2000 04:58:47 +0900 [thread overview]
Message-ID: <hvou2gbmow8.fsf@serein.m17n.org> (raw)
In-Reply-To: <hvozoq3mux1.fsf@serein.m17n.org> (Tanaka Akira's message of "07 May 2000 02:48:42 +0900")
In article <hvozoq3mux1.fsf@serein.m17n.org>,
Tanaka Akira <akr@m17n.org> writes:
> Possibly. But NetBSD has no problem...
I found the difference between FreeBSD and NetBSD.
FreeBSD fails to kill(-PGID,0) for zombie process but NetBSD (and
Linux) succeeds.
FreeBSD:
> | Z:akr@dhcp21% kdump|egrep 'kill|fork|exit|setpgid'
> | 29256 zsh CALL fork # zsh: fork for echo
> | 29256 zsh RET fork 29257/0x7249
> | 29257 zsh RET fork 0
> | 29257 zsh CALL setpgid(0,0x7249) # echo: setpgid(0,29257)
> | 29257 zsh RET setpgid 0
> | 29256 zsh CALL fork # zsh: fork for sleep
> | 29256 zsh RET fork 29258/0x724a
> | 29257 zsh CALL exit(0) # echo: exit(0)
29257(echo) is zombie now.
> | 29258 zsh RET fork 0
> | 29258 zsh CALL kill(0xffff8db7,0)
> | 29258 zsh RET kill -1 errno 3 No such process
The process to be sleep command tries to check a leader is exists...
0xffff8db7 is -29257. kill(-29257,0) is failed.
> | 29258 zsh CALL setpgid(0,0x724a) # sleep: setpgid(0,29258)
> | 29258 zsh RET setpgid 0
So, it decides to be a leader itself.
NetBSD:
> | Z:akr@netbsd% kdump|egrep 'kill|fork|exit|setpgid'
> | 16519 zsh CALL fork # zsh: fork for echo
> | 16519 zsh RET fork 16520/0x4088
> | 16520 zsh RET fork 0
> | 16520 zsh CALL setpgid(0,0x4088)
> | 16520 zsh RET setpgid 0
> | 16520 zsh CALL exit(0) # echo: exit(0)
16520(echo) is zombie now.
> | 16519 zsh CALL fork # zsh: fork for sleep
> | 16519 zsh RET fork 16521/0x4089
> | 16521 zsh RET fork 0
> | 16521 zsh CALL kill(0xffffbf78,0)
> | 16521 zsh RET kill 0
The process to be sleep command tries to check a leader is exists...
0xffffbf78 is -16520. kill(-16520,0) is succeed.
> | 16521 zsh CALL setpgid(0,0x4088) # sleep: setpgid(0,16520)
> | 16521 zsh RET setpgid 0
So, it comes into the process group of echo.
I confirmed following modification prevents the problem. But
definitely this is too radical...
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.7
diff -u -r1.7 exec.c
--- Src/exec.c 2000/05/04 13:40:05 1.7
+++ Src/exec.c 2000/05/06 19:53:20
@@ -2466,7 +2466,7 @@
}
} else if (thisjob != -1 && cl) {
if (jobtab[list_pipe_job].gleader && (list_pipe || list_pipe_child)) {
- if (killpg(jobtab[list_pipe_job].gleader, 0) == -1 ||
+ if (/* killpg(jobtab[list_pipe_job].gleader, 0) == -1 || */
setpgrp(0L, jobtab[list_pipe_job].gleader) == -1) {
jobtab[list_pipe_job].gleader =
jobtab[thisjob].gleader = (list_pipe_child ? mypgrp : getpid());
--
Tanaka Akira
next prev parent reply other threads:[~2000-05-06 19:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-06 15:03 Tanaka Akira
2000-05-06 17:08 ` Bart Schaefer
2000-05-06 17:48 ` Tanaka Akira
2000-05-06 18:45 ` Bart Schaefer
2000-05-06 19:03 ` Tanaka Akira
2000-05-06 19:58 ` Tanaka Akira [this message]
2000-05-06 21:23 ` Bart Schaefer
2000-05-06 21:41 ` Tanaka Akira
2000-05-08 8:48 Sven Wischnowsky
2000-05-08 9:17 ` Tanaka Akira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=hvou2gbmow8.fsf@serein.m17n.org \
--to=akr@m17n.org \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).