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

PATCH (and another bug report): Re: zsh script and SIGCONT



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



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