Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: fg/bg on FreeBSD.
- X-seq: zsh-workers 11235
- From: Tanaka Akira <akr@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: fg/bg on FreeBSD.
- Date: 07 May 2000 02:48:42 +0900
- In-reply-to: <1000506170828.ZM2063@xxxxxxxxxxxxxxxxxxxxxxx> (Bart Schaefer's message of "Sat, 6 May 2000 17:08:28 +0000")
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <hvo3dnvoh59.fsf@xxxxxxxxxxxxxxx> <1000506170828.ZM2063@xxxxxxxxxxxxxxxxxxxxxxx>
In article <1000506170828.ZM2063@xxxxxxxxxxxxxxxxxxxxxxx>,
"Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> Why is the PGID of sleep different on FreeBSD? Did it change after the
> sleep was started because the echo exited?
Possibly. But NetBSD has no problem...
| Z:akr@dhcp21% ktrace -i zsh -f
| dhcp21% echo|sleep 10
| ^Z
| zsh: done echo |
| zsh: suspended sleep 10
| dhcp21% jobs -l
| [1] + 29257 done echo |
| 29258 suspended sleep 10
| dhcp21% ps j29258
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29258 29256 29258 94d480 1 T p3 0:00.00 sleep 10
| dhcp21% bg
| [1] + done echo |
| continued sleep 10
| dhcp21% ps j29258
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29258 29256 29258 94d480 1 T p3 0:00.00 sleep 10
| dhcp21% kill -9 29258
| [1] + done echo |
| killed sleep 10
| dhcp21% exit
| 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)
| 29258 zsh RET fork 0
| 29258 zsh CALL kill(0xffff8db7,0)
| 29258 zsh RET kill -1 errno 3 No such process
| 29258 zsh CALL setpgid(0,0x724a) # sleep: setpgid(0,29258)
Hm. The process to be sleep command set its PGID itself.
| 29258 zsh RET setpgid 0
| 29256 zsh CALL kill(0xffff8db6,0)
| 29256 zsh RET kill 0
| 29256 zsh CALL fork # zsh: fork for ps
| 29256 zsh RET fork 29259/0x724b
| 29259 zsh RET fork 0
| 29259 zsh CALL setpgid(0,0x724b)
| 29259 zsh RET setpgid 0
| 29259 ps CALL exit(0)
| 29256 zsh CALL kill(0xfffe7960,0)
| 29256 zsh RET kill -1 errno 3 No such process
| 29256 zsh CALL kill(0xffff8db7,0x13) # zsh: kill(-29257,SIGCONT)
| 29256 zsh RET kill -1 errno 3 No such process
| 29256 zsh CALL fork # zsh: fork for ps
| 29256 zsh RET fork 29260/0x724c
| 29260 zsh RET fork 0
| 29260 zsh CALL setpgid(0,0x724c)
| 29260 zsh RET setpgid 0
| 29260 ps CALL exit(0)
| 29256 zsh CALL kill(0xfffe7960,0)
| 29256 zsh RET kill -1 errno 3 No such process
| 29256 zsh CALL kill(0x724a,0x9)
| 29256 zsh RET kill 0
| killed sleep 10
| 29256 zsh CALL exit(0)
| Z:akr@dhcp21%
> Please try the same test, but replace "echo" with "sleep 9" so that you
> can stop both jobs before either one of them exits. Then see what the
> PGID of the second sleep is.
OK.
| Z:akr@dhcp21% ktrace -i zsh -f
| dhcp21% sleep 100|sleep 200
| ^Z
| zsh: suspended sleep 100 | sleep 200
9 seconds are too short to check it...
| dhcp21% jobs -l
| [1] + 29245 suspended sleep 100 |
| 29246 suspended sleep 200
| dhcp21% ps j29245; ps j29246
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29245 29244 29245 94d480 2 T p3 0:00.00 sleep 100
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29246 29244 29245 94d480 2 T p3 0:00.00 sleep 200
PGID is first sleep's PID. It's good.
| dhcp21% bg
| [1] + continued sleep 100 | sleep 200
| dhcp21% ps j29245; ps j29246
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29245 29244 29245 94d480 2 I p3 0:00.00 sleep 100
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 29246 29244 29245 94d480 2 I p3 0:00.00 sleep 200
It's successfully resumed.
| dhcp21% kill %1
| [1] + terminated sleep 100 | sleep 200
| dhcp21% exit
| Z:akr@dhcp21%
Note that this is the result of similar test on NetBSD.
| Z:akr@netbsd% ktrace -i zsh -f
| netbsd% echo|sleep 100
| ^Z
| zsh: done echo |
| zsh: suspended sleep 100
| netbsd% jobs -l
| [1] + 16520 done echo |
| 16521 suspended sleep 100
| netbsd% ps j16521
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 16521 16519 16520 c09fae40 1 T p1 0:00.01 sleep 100
| netbsd% bg
| [1] + done echo |
| continued sleep 100
| netbsd% ps j16521
| USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
| akr 16521 16519 16520 c09fae40 1 S p1 0:00.01 sleep 100
| netbsd% kill %1
| [1] + done echo |
| terminated sleep 100
| netbsd% exit
| 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)
| 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
| 16521 zsh CALL setpgid(0,0x4088) # sleep: setpgid(0,16520)
It setpgid itself to 16520(echo's PID) correctly.
| 16521 zsh RET setpgid 0
| 16519 zsh CALL fork
| 16519 zsh RET fork 16522/0x408a
| 16522 zsh RET fork 0
| 16522 zsh CALL setpgid(0,0x408a)
| 16522 zsh RET setpgid 0
| 16519 zsh CALL kill(0xffff8acf,0)
| 16519 zsh RET kill -1 errno 3 No such process
| 16519 zsh CALL kill(0xffffbf78,0x13)
| 16519 zsh RET kill 0
| 16519 zsh CALL fork
| 16519 zsh RET fork 16523/0x408b
| 16523 zsh RET fork 0
| 16523 zsh CALL setpgid(0,0x408b)
| 16523 zsh RET setpgid 0
| 16519 zsh CALL kill(0xffff8acf,0)
| 16519 zsh RET kill -1 errno 3 No such process
| 16519 zsh CALL kill(0xffffbf78,0xf)
| 16519 zsh RET kill 0
| 16519 zsh CALL exit(0)
| Z:akr@netbsd%
--
Tanaka Akira
Messages sorted by:
Reverse Date,
Date,
Thread,
Author