From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25458 invoked by alias); 24 Apr 2015 15:26:21 -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: 34955 Received: (qmail 24568 invoked from network); 24 Apr 2015 15:26:08 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-f794b6d000001495-1b-553a608ffee3 Date: Fri, 24 Apr 2015 16:25:42 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: Using "source" in a function breaks job control Message-id: <20150424162542.2efb36a3@pwslap01u.europe.root.pri> In-reply-to: References: <5537E450.9060205@thequod.de> <20150422222627.1f6154e9@ntlworld.com> <150422215539.ZM14251@torch.brasslantern.com> <20150423211331.5ea4baf0@ntlworld.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCLMWRmVeSWpSXmKPExsVy+t/xa7r9CVahBjO3MFscbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujDOnprMVtIlXHPn4g7GB8YtgFyMnh4SAicTnf7dZIWwxiQv3 1rN1MXJxCAksZZS4sP8YE4Qzg0mi8d9rFghnG6PEvxWL2UFaWARUJbYevAHWziZgKDF102zG LkYODhEBbYn2j2IgYWEBG4lNt16ygdi8AvYSqybeZQSxOQWCJfZP28wKMfMTo8TTpReZQBL8 AvoSV/9+YoI4yV5i5pUzjBDNghI/Jt9jAbGZBbQkNm9rYoWw5SU2r3nLDGILCahL3Li7m30C o9AsJC2zkLTMQtKygJF5FaNoamlyQXFSeq6RXnFibnFpXrpecn7uJkZI2H7dwbj0mNUhRgEO RiUe3oZLlqFCrIllxZW5hxglOJiVRHgvx1qFCvGmJFZWpRblxxeV5qQWH2KU5mBREueduet9 iJBAemJJanZqakFqEUyWiYNTqoFxXclk9p+/Su1V8w/xc+Scka6zaN+tHiXsIuP6Kj14veri Av7o4KoLPXyW+9ctlA6VK3uWrbrx+MzAKMPDyxY0b8qa2jitV1d9aU7XCb6FqpE2De/Uv5/6 pST8In1Rc6r74XbpjCNbLrm31k3SXbpL+d3qdUnRJgcTuko0frFMWq4abmLlkKvEUpyRaKjF XFScCAAO601DVwIAAA== On Thu, 23 Apr 2015 23:22:55 -0700 Bart Schaefer wrote: > On Thu, Apr 23, 2015 at 1:13 PM, Peter Stephenson > wrote: > > On Wed, 22 Apr 2015 21:55:39 -0700 > > Bart Schaefer wrote: > >> It has something to do with tracking the job table. > > > > Looks like we lost STAT_SUPERJOB in the flags of the job that got > > created when we forked. > > That was the needed clue. The problem is that list_pipe_job is wrong > following the return from source(). The complications are that (1) > list_pipe_job is static to exec.c whereas source() is in init.c, and > (2) when I tried exporting list_pipe_job so it could be saved/restored > in source(), it fixed this issue but caused the test for "status of > recently exited background jobs is recorded" to fail (which confuses > me, because I can't see any reason source() would get involved in that > test). The variable needs adding to the set in execlist(). I tried a few similarly named variables last night but not that one. Apparently a few more verses need adding to the Nibelungenlied. * Allen Edeln gebiet ich Andacht, * Hohen und Niedern von Heimdalls Geschlecht; * Ich will list_pipe's Wirken kuenden * Die aeltesten Sagen, der ich mich entsinne... > Perhaps source() should be using execsave()/execrestore() instead of > the stack of local copies of the job state globals that it maintains? It's possible --- the current split between source() and execlist() is certainly icky --- though I'm not sure whether or not source() needs to be as boxed in as eval and similar or if it'll create subtle problems. (Actually, if it didn't, it would be a new record.) pws diff --git a/Src/exec.c b/Src/exec.c index 2a8185c..60b79c6 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1146,7 +1146,7 @@ execlist(Estate state, int dont_change_job, int exiting) Wordcode next; wordcode code; int ret, cj, csp, ltype; - int old_pline_level, old_list_pipe; + int old_pline_level, old_list_pipe, old_list_pipe_job; zlong oldlineno; /* * ERREXIT only forces the shell to exit if the last command in a && @@ -1159,10 +1159,11 @@ execlist(Estate state, int dont_change_job, int exiting) cj = thisjob; old_pline_level = pline_level; old_list_pipe = list_pipe; + old_list_pipe_job = list_pipe_job; oldlineno = lineno; if (sourcelevel && unset(SHINSTDIN)) - pline_level = list_pipe = 0; + pline_level = list_pipe = list_pipe_job = 0; /* Loop over all sets of comands separated by newline, * * semi-colon or ampersand (`sublists'). */ @@ -1397,6 +1398,7 @@ sublist_done: } pline_level = old_pline_level; list_pipe = old_list_pipe; + list_pipe_job = old_list_pipe_job; lineno = oldlineno; if (dont_change_job) thisjob = cj;