zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: How to misplace an entire pipeline
Date: Sun, 07 Aug 2011 14:43:59 -0700	[thread overview]
Message-ID: <110807144359.ZM27903@torch.brasslantern.com> (raw)
In-Reply-To: <20110807185002.6a042cab@pws-pc.ntlworld.com>

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.


  reply	other threads:[~2011-08-07 21:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-06  3:31 Bart Schaefer
2011-08-07 17:50 ` Peter Stephenson
2011-08-07 21:43   ` Bart Schaefer [this message]
2011-08-08  4:05     ` Bart Schaefer
2011-08-08 18:27       ` Peter Stephenson
2011-08-09  6:10         ` Bart Schaefer
2011-08-09 20:19           ` Peter Stephenson
2011-08-13 18:52             ` Bart Schaefer
2011-08-13 20:15               ` Bart Schaefer
2011-09-12 13:51               ` Alexey I. Froloff
2011-09-12 16:03                 ` Bart Schaefer
2011-09-12 16:18                   ` Bart Schaefer
2011-09-12 16:35                     ` Peter Stephenson
2011-09-15 14:57                       ` Alexey I. Froloff
2011-09-16 16:16                         ` Bart Schaefer
2011-09-12 16:27                   ` Alexey I. Froloff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=110807144359.ZM27903@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).