From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7331 invoked by alias); 20 Feb 2012 17:41:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30242 Received: (qmail 20183 invoked from network); 20 Feb 2012 17:41:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120220094100.ZM359@torch.brasslantern.com> Date: Mon, 20 Feb 2012 09:41:00 -0800 In-reply-to: <20120220151309.4cc1a83d@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: suspend (^Z) behavior while a function is running is unclear" (Feb 20, 3:13pm) References: <20120220130259.GB7797@xvii.vinc17.org> <20120220151309.4cc1a83d@pwslap01u.europe.root.pri> <20120220160944.GC7797@xvii.vinc17.org> <20120220163557.672588e2@pwslap01u.europe.root.pri> In-reply-to: <20120220163557.672588e2@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: suspend (^Z) behavior while a function is running is unclear" (Feb 20, 4:35pm) X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Subject: Re: suspend (^Z) behavior while a function is running is unclear MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Feb 20, 3:13pm, Peter Stephenson wrote: > Subject: Re: suspend (^Z) behavior while a function is running is unclear > > +Note that if the job running in the foreground is a shell function, > +then suspending it will have the effect of causing the shell to fork. [...] > + > +The same behaviour is found when the shell is executing code as the > +right hand side of a pipeline, in order that the entire pipeline > +can be managed as a single job. In fact it also happens when executing any "complex command" such as a foreach loop: torch% foreach foo (a b c) { sleep 5 } zsh: suspended for foo in a b c; do; sleep 5; done On Feb 20, 4:35pm, Peter Stephenson wrote: > Subject: Re: suspend (^Z) behavior while a function is running is unclear > > On Mon, 20 Feb 2012 17:09:45 +0100 > Vincent Lefevre wrote: > > Now I'm thinking whether there should be an option to control that. > > Indeed, some functions may fail to work correctly if they are suspended > > in such a way. Some functions or { list } could be marked as not > > backgroundable, e.g. by setting an option at the beginning, in which > > case the ^Z could be ignored. This is already partly in place: 2011-08-14 Barton E. Schaefer * 29677: Src/exec.c, Src/signals.c, Src/zsh.h: flag jobs that are builtins running in the current shell, and if they control a pipeline, do not allow the external processes in that pipeline to become suspended when the foreground shell cannot suspend. torch% foreach foo (a b c) { sleep 5 } | : zsh: job can't be suspended Prior to 29677, ^Z here would have resulted in the loop becoming both orphaned and stopped. But here the foreach is already in a separate process because of the way zsh manages pipelines. > Useful, but I'm not sure an option is the right way of doing this... I > should think you'd want to do something like: > > { > stty susp undef > ... > } always { > stty susp '^z' > } I'm not sure that's the right semantics. Does one want to disable the tty suspend character or just ingore the TSTP signal? What if "emacs" in the original example was replaced by running another shell? > (By the way, I'm wondering how many of the other shells simply execute > to the end of the parent function when they see the "emacs" process > suspended?) Preventing that behavior in a loop construct is I believe one of the reasons zsh changed to behave the way it does. (Another fine project from Wischnowsky Construction Co., as I recall.)