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

Re: fg/bg on FreeBSD.



In article <1000506212352.ZM8935@xxxxxxxxxxxxxxxxxxxxxxx>,
  "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> writes:

> What happens if you reverse the order of the test?
> 
>           if (setpgrp(0L, jobtab[list_pipe_job].gleader) == -1 ||
> 	      killpg(jobtab[list_pipe_job].gleader, 0) == -1) {

Wow!  It's good idea.

| Z:akr@dhcp21% ktrace -i Src/zsh -f 
| dhcp21% echo|sleep 100
| ^Z
| zsh: done       echo | 
| zsh: suspended  sleep 100
| dhcp21% jobs -l
| [1]  + 50065 done       echo | 
|        50066 suspended  sleep 100
| dhcp21% ps j50066
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  50066 50064 50065 97d1c0    1 T     p0    0:00.00 sleep 100
| dhcp21% bg
| [1]  + done       echo | 
|        continued  sleep 100
| dhcp21% ps j50066
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  50066 50064 50065 97d1c0    1 S     p0    0:00.00 sleep 100

It's resumed successfully.

| dhcp21% 
| [1]  + done       echo | sleep 100
| dhcp21% exit

> What I'm trying to discover is whether killpg() continues to fail after
> a process is successfully added to the group.

| Z:akr@dhcp21% kdump|egrep 'kill|fork|exit|setpgid|wait'
|  50064 zsh      CALL  fork
|  50064 zsh      RET   fork 50065/0xc391
|  50065 zsh      RET   fork 0
|  50065 zsh      CALL  setpgid(0,0xc391)
|  50065 zsh      RET   setpgid 0
|  50064 zsh      CALL  fork
|  50064 zsh      RET   fork 50066/0xc392
|  50065 zsh      CALL  exit(0)

Now, echo is zombie.

|  50066 zsh      RET   fork 0
|  50066 zsh      CALL  setpgid(0,0xc391)
|  50066 zsh      RET   setpgid 0

sleep comes into the group successfully.

|  50066 zsh      CALL  kill(0xffff3c6f,0)
|  50066 zsh      RET   kill 0

killpg succeeds.

|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 50065/0xc391
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 0
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 50066/0xc392

echo is waited.

|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 0
|  50064 zsh      CALL  fork
|  50064 zsh      RET   fork 50067/0xc393
|  50067 zsh      RET   fork 0
|  50067 zsh      CALL  setpgid(0,0xc393)
|  50067 zsh      RET   setpgid 0
|  50067 ps       CALL  exit(0)
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 50067/0xc393
|  50064 zsh      CALL  kill(0xfffe7960,0)
|  50064 zsh      RET   kill -1 errno 3 No such process
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 0
|  50064 zsh      CALL  kill(0xffff3c6f,0x13)
|  50064 zsh      RET   kill 0
|  50064 zsh      CALL  fork
|  50064 zsh      RET   fork 50071/0xc397
|  50071 zsh      RET   fork 0
|  50071 zsh      CALL  setpgid(0,0xc397)
|  50071 zsh      RET   setpgid 0
|  50071 ps       CALL  exit(0)
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 50071/0xc397
|  50064 zsh      CALL  kill(0xfffe7960,0)
|  50064 zsh      RET   kill -1 errno 3 No such process
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff530,0x3,0)
|  50064 zsh      RET   wait4 0
|  50064 zsh      CALL  kill(0xffff3c6f,0xf)
|  50064 zsh      RET   kill 0
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff5c0,0x3,0)
|  50064 zsh      RET   wait4 50066/0xc392
|  50064 zsh      CALL  wait4(0xffffffff,0xbfbff5c0,0x3,0)
|  50064 zsh      RET   wait4 -1 errno 10 No child processes
|  50064 zsh      CALL  exit(0)
-- 
Tanaka Akira



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