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

Re: fg/bg on FreeBSD.



In article <1000506184503.ZM6391@xxxxxxxxxxxxxxxxxxxxxxx>,
  "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> writes:

> OK, now, can you "fg" it, wait for the first sleep (but not the second)
> to exit, then ^Z again and check the PGIDs?

| Z:akr@dhcp21% ktrace -i zsh -f
| dhcp21% sleep 30|sleep 100
| ^Z
| zsh: suspended  sleep 30 | sleep 100
| dhcp21% jobs -l
| [1]  + 29347 suspended  sleep 30 | 
|        29348 suspended  sleep 100
| dhcp21% ps j   
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  29335 29333 29335 a0fe80    0 Is    p0    0:00.11 /home/akr/.zsh/arch/i386-unknown-freebsd4.0/bin/zsh -l
| akr  29346 29335 29346 a0fe80    1 S     p0    0:00.07 zsh -f
| akr  29347 29346 29347 a0fe80    2 T     p0    0:00.00 sleep 30
| akr  29348 29346 29347 a0fe80    2 T     p0    0:00.00 sleep 100
| akr  29349 29346 29349 a0fe80    1 R+    p0    0:00.00 ps j

PGID of `sleep 100' is both 29347.  No problem.

| dhcp21% fg
| [1]  + continued  sleep 30 | sleep 100
| ^Z
| zsh: done       sleep 30 | 
| zsh: suspended  sleep 100
| dhcp21% ps j
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  29335 29333 29335 a0fe80    0 Is    p0    0:00.11 /home/akr/.zsh/arch/i386-unknown-freebsd4.0/bin/zsh -l
| akr  29346 29335 29346 a0fe80    1 S     p0    0:00.08 zsh -f
| akr  29348 29346 29347 a0fe80    1 T     p0    0:00.00 sleep 100
| akr  29365 29346 29365 a0fe80    1 R+    p0    0:00.00 ps j
| akr  29352 29350 29352 9099c0    0 Ss+   p1    0:00.12 /home/akr/.zsh/arch/i386-unknown-freebsd4.0/bin/zsh -l
| dhcp21% 

The PGID is not changed: 29347.

> Another test to try:
> 
> 	echo | sleep 100 | sleep 200
> 
> If you ^Z this, do both sleeps get the same PGID, or do they each become
> their own process group?  (I'm hoping the latter, for sanity, otherwise
> it's a guessing game as to what PID becomes the leader.)

Wow!  This cannot stop with ^Z.

| Z:akr@dhcp21% zsh -f
| dhcp21% echo $$
| 29385
| dhcp21% tty
| /dev/ttyp0
| dhcp21% echo | sleep 100 | sleep 200
| ^Z

`ps j' from another termianl before ^Z:

| Z:akr@dhcp21% ps j         
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  29335 29333 29335 a0fe80    0 Ss    p0    0:00.12 /home/akr/.zsh/arch/i386
| akr  29385 29335 29385 a0fe80    1 S     p0    0:00.03 zsh -f
| akr  29388 29385 29388 a0fe80    1 S     p0    0:00.00 sleep 100
| akr  29389 29385 29389 a0fe80    1 S+    p0    0:00.00 sleep 200
| akr  29352 29350 29352 9099c0    0 Ss    p1    0:00.14 /home/akr/.zsh/arch/i386
| akr  29390 29352 29390 9099c0    1 R+    p1    0:00.00 ps j

Hm.  Two sleep commands has own PGID.  They are both process group leader.

`ps j' from another termianl after ^Z:

| Z:akr@dhcp21% ps j
| USER   PID  PPID  PGID   SESS JOBC STAT  TT       TIME COMMAND
| akr  29335 29333 29335 a0fe80    0 Is    p0    0:00.12 /home/akr/.zsh/arch/i386
| akr  29385 29335 29385 a0fe80    1 S     p0    0:00.03 zsh -f
| akr  29388 29385 29388 a0fe80    1 S     p0    0:00.00 sleep 100
| akr  29389 29385 29389 a0fe80    1 T+    p0    0:00.00 sleep 200
| akr  29352 29350 29352 9099c0    0 Ss    p1    0:00.14 /home/akr/.zsh/arch/i386
| akr  29391 29352 29391 9099c0    1 R+    p1    0:00.00 ps j

Only `sleep 200' is stopped because foreground process group for ttyp0
is 29389.  Maybe.
-- 
Tanaka Akira



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