Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Jobs unexpectedly disowned



On Wed, 2019-07-31 at 14:25 +0000, Peter Stephenson wrote:
> On Sun, 2019-07-21 at 08:19 +0200, Roman Perepelitsa wrote:
> > I'm seeing weird behavior with jobs getting disowned and I'm not sure
> > whether it's intended.
> >  
> >     function f2() { sleep 1 &; true }
> >     function g2() { f2; jobs; wait }
> >  
> >     echo g2; g2
> >  
> > When ran from `zsh -df` I get this:
> >  
> >     g2
> >     [2] 31061
> 
> We're not seeing job information because STAT_NOPRINT is being or'ed into the
> job status by this code within execpline().
> 
> 	    if (list_pipe || (pline_level && !(how & Z_TIMED)))
> 		jn->stat |= STAT_NOPRINT;
> 
> because pline_level is non-zero.

This might be good enough --- a job that's been backgrounded has
been told not to use the terminal and if it's semi-detached in
that fashion we probably want it to show up as job.

pws

diff --git a/Src/exec.c b/Src/exec.c
index 2acb2c0bc..e81053d67 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1690,7 +1690,8 @@ execpline(Estate state, wordcode slcode, int how, int last1)
 
 	    lastwj = thisjob = newjob;
 
-	    if (list_pipe || (pline_level && !(how & Z_TIMED)))
+	    if (list_pipe || (pline_level && !(how & Z_TIMED) &&
+			      !(jn->stat & STAT_NOSTTY)))
 		jn->stat |= STAT_NOPRINT;
 
 	    if (nowait) {



Messages sorted by: Reverse Date, Date, Thread, Author