From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6837 invoked from network); 12 Dec 1999 20:08:51 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 12 Dec 1999 20:08:51 -0000 Received: (qmail 8452 invoked by alias); 12 Dec 1999 20:08:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9005 Received: (qmail 8438 invoked from network); 12 Dec 1999 20:08:39 -0000 From: "Bart Schaefer" Message-Id: <991212200800.ZM8901@candle.brasslantern.com> Date: Sun, 12 Dec 1999 20:07:59 +0000 In-Reply-To: Comments: In reply to nirva@ishiboo.com (Danny Dulai) "RE: zsh script and SIGCONT" (Dec 12, 11:50am) References: X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk, nirva@ishiboo.com (Danny Dulai) Subject: PATCH (and another bug report): Re: zsh script and SIGCONT MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 12, 11:50am, Danny Dulai wrote: } Subject: RE: zsh script and SIGCONT } } (~) % exec zsh } (~) % echo $ZSH_VERSION } 3.1.6-pws-11 } (~) % cat p2 } while :; do } echo helu; } sleep 1 } done } (~) % zsh p2 } helu } helu } } zsh: 5896 suspended zsh p2 } (~) % bg } [1] + continued zsh p2 } (~) % } [1] + 5896 done zsh p2 Even worse than this ... if you read the script with ". p2", then ^Z only stops the "sleep 1" and the loop keeps going. All three cases ought to behave the same as executing the loop at the top-level prompt. I spent a while trying to trace through this, but it's nearly impossible to use a debugger in combination with tty stop signals, and zsh's job control is one of those places where "reading zsh source code makes you go blind," as Tom Christiansen has said. I believe the script case has something to do with both zsh and sleep getting the TSTP (which zsh doesn't have a special handler for); zsh forks to background the entire while loop, and therefore the parent shell exits from the loop -- but so does the forked child, for reasons that I can't follow. However, in the case of a script, zsh doesn't need to do any of this; the script can start and stop as its own process. So the following appears to fix the script case, but I still don't know what's going on with ".". Index: Src/exec.c =================================================================== @@ -945,7 +945,7 @@ jn->stat & STAT_DONE && lastval2 & 0200) killpg(mypgrp, lastval2 & ~0200); - if (!list_pipe_child && !lpforked && !subsh && + if (!list_pipe_child && !lpforked && !subsh && jobbing && (list_pipe || last1 || pline_level) && ((jn->stat & STAT_STOPPED) || (list_pipe_job && pline_level && -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com