Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

fg/bg on FreeBSD.



On FreeBSD 3.4 and 4.0, fg/bg may not activate suspended process.

| Z:akr@dhcp21% ktrace zsh -f

Start zsh with kernel trace.

| dhcp21% echo|sleep 10
| ^Z
| zsh: done       echo | 
| zsh: suspended  sleep 10

Start `echo|sleep 10' and immediately suspend it by <C-z>.

| dhcp21% jobs -l
| [1]  + 754 done       echo | 
|        755 suspended  sleep 10

Report the job info.
echo's PID is 754 and it's already done.
sleep's PID is 755 and it's suspended.

| dhcp21% ps j755
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr    755   753   755 92fdc0    1 T     p1    0:00.00 sleep 10

Check the process status by ps.
`T' on `STAT' field shows that it's stopped.

| dhcp21% bg
| [1]  + done       echo | 
|        continued  sleep 10

Resume the job on a background.
It seems resumed, but ...

| dhcp21% ps j755
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr    755   753   755 92fdc0    1 T     p1    0:00.00 sleep 10

Check the process status by ps again.
The process is not resumed.

| dhcp21% kill -9 755
| [1]  + done       echo | 
|        killed     sleep 10
| dhcp21% exit

kill the process and exit.

| Z:akr@dhcp21% kdump|grep kill
|    753 zsh      CALL  kill(0xfffffd0d,0)                # kill(-755,0)
|    753 zsh      RET   kill 0
|    753 zsh      CALL  kill(0xfffe7960,0)                # kill(-100000,0)
|    753 zsh      RET   kill -1 errno 3 No such process
|    753 zsh      CALL  kill(0xfffffd0e,0x13)             # kill(-754,SIGCONT)
|    753 zsh      RET   kill -1 errno 3 No such process
|    753 zsh      CALL  kill(0xfffe7960,0)                # kill(-100000,0)
|    753 zsh      RET   kill -1 errno 3 No such process
|    753 zsh      CALL  kill(0x2f3,0x9)                   # kill(755,SIGKILL)
|    753 zsh      RET   kill 0
|                killed     sleep 10
| Z:akr@dhcp21% 

There are `kill system call' called by zsh.  I suppose the system call
correspondding to the `bg' is `kill(-754,SIGCONT)'.  It's failed
because the process group 754 is not exist.  I think it is wrong that
the sleep process has process group 755 rather than 754.  Because zsh
assigns a process group as a process number of first component of a
pipe.

Note that if `fg' is used for resume the job, zsh hangs.
-- 
Tanaka Akira



Messages sorted by: Reverse Date, Date, Thread, Author