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

Re: fg/bg on FreeBSD.



On May 7,  2:48am, Tanaka Akira wrote:
} Subject: Re: fg/bg on FreeBSD.
}
} 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...

Yes, what I'm wondering is whether this is a FreeBSD bug.
 
} | Z:akr@dhcp21% ktrace -i zsh -f
} | dhcp21% sleep 100|sleep 200
} | ^Z
} | zsh: suspended  sleep 100 | sleep 200
} | 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.

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

If the PGID is going to change every time the group leader exits, then
we've got a problem -- we can't simply record the group leader's PID and
keep using it unless we arrange for a group leader that's guaranteed to
stay alive for the whole pipeline.

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.)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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