Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to misplace an entire pipeline
On Aug 7, 6:50pm, Peter Stephenson wrote:
}
} This is code I don't go near
Obviously somebody went near it at some point not as long ago as Sven,
because it behaved differently in 4.2.x.
Zsh does still know about the pipeline, because if you explicitly wait
for the subjobs by PID it does block rather than saying "not a child of
this shell". findproc() is able to see them (so it's not related to
the recent go-round with that.)
(By the way, arguably "wait" ought to continue the job if it's stopped,
which it does if you wait for it by job number but does not if you wait
for it by PID.)
Starting from
torch% sleep 10 | sleep 20 | true
Then hit ^Z, then
torch% ps ax | grep slee
27868 pts/2 T 0:00 sleep 10
27869 pts/2 T 0:00 sleep 20
27873 pts/2 S+ 0:00 grep slee
torch% wait 27868
Here we are in bin_fg right after the findproc():
(gdb) p *j
$4 = {gleader = 27868, other = 0, stat = 1139, pwd = 0x0, procs = 0x9f83070,
auxprocs = 0x0, filelist = 0x0, stty_in_env = 0, ty = 0x0}
(gdb) p *p
$5 = {next = 0x9f83128, pid = 27868,
text = "sleep 10", '\0' <repeats 71 times>, status = 5247, ti = {ru_utime = {
tv_sec = 0, tv_usec = 0}, ru_stime = {tv_sec = 0, tv_usec = 1999},
ru_maxrss = 0, ru_ixrss = 0, ru_idrss = 0, ru_isrss = 0, ru_minflt = 242,
ru_majflt = 0, ru_nswap = 0, ru_inblock = 0, ru_oublock = 0,
ru_msgsnd = 0, ru_msgrcv = 0, ru_nsignals = 0, ru_nvcsw = 3,
ru_nivcsw = 0}, bgtime = {tv_sec = 1312751280, tv_usec = 828721},
endtime = {tv_sec = 1312751282, tv_usec = 474423}}
If I wait for the "sleep 20" instead:
(gdb) p *j
$2 = {gleader = 27868, other = 0, stat = 1139, pwd = 0x0, procs = 0x9f83070,
auxprocs = 0x0, filelist = 0x0, stty_in_env = 0, ty = 0x0}
(gdb) p *p
$3 = {next = 0x0, pid = 27869, text = "sleep 20", '\0' <repeats 71 times>,
status = 5247, ti = {ru_utime = {tv_sec = 0, tv_usec = 0}, ru_stime = {
tv_sec = 0, tv_usec = 999}, ru_maxrss = 0, ru_ixrss = 0, ru_idrss = 0,
ru_isrss = 0, ru_minflt = 242, ru_majflt = 0, ru_nswap = 0,
ru_inblock = 0, ru_oublock = 0, ru_msgsnd = 0, ru_msgrcv = 0,
ru_nsignals = 0, ru_nvcsw = 3, ru_nivcsw = 1}, bgtime = {
tv_sec = 1312751280, tv_usec = 829868}, endtime = {tv_sec = 1312751282,
tv_usec = 474440}}
Notice that at some point "sleep 10" was made the process group leader
for the whole pipeline.
Now, here's an interesting tidbit:
torch% jobs %?foo
jobs: job not found: ?foo
torch% jobs %?sleep
jobs: %?sleep: no such job
Note the difference? The latter message means that getjob() found the
pipeline, but either it's _not_ STAT_INUSE or it _is_ STAT_NOPRINT. So
I think what we have here is a simple failure to communicate.
Unfortunately I can't chase this any further this afternoon.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author