Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: setopt monitor in non-interactive shell
- X-seq: zsh-workers 22656
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: setopt monitor in non-interactive shell
- Date: Mon, 21 Aug 2006 22:01:06 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
There's a bug report on sourceforge:
>[ 1413647 ] using eval in monitor mode doesn't work!
>Submitted By:
>Thomas Eriksson - arne Date Submitted:
>2006-01-24 04:21
>Summary: (?)
>using eval in monitor mode doesn't work!
>I have tested the following code with zsh 4.2.6 on
>Ubuntu Breezy:
>
>Consider this trivial code
>
>#!/bin/zsh
>set -m
>eval /bin/echo foo bar
>## EOF
>
>Interpreting it with zsh will make zsh "hang" at the
>eval command, instead of executing echo!
>
>This does not seem to affect builtins.
>
>I have tried this on recent versions of 'bash' and
>'pdksh' with no problem.
The hang happens, because the shell hasn't properly set up its process
group because the usual interactive handling wasn't done; enabling the
monitor option made it think it could set the process group. This
caused the child forked for /bin/echo (it's not specific to eval) to be
suspended in a way the parent shell wasn't prepared to handle. Or
something.
The monitor option in zsh is tied to being in an interactive shell. I
think the only answer, however unpleasing it may seem, is to make some
attempt but give up without trying to reinitialise the shell which is
the only way it's actually going to work in a case like this.
The code that makes "some attempt" is the same as that which tries to
set up the monitor option in the first place: chances are the monitor
option wasn't set because this failed last time round, so I'm not sure
how useful this is.
I don't really know much about terminal handling. If anyone else thinks
they can fix it properly please do so.
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.30
diff -u -r1.30 options.c
--- Src/options.c 25 Jul 2006 18:10:38 -0000 1.30
+++ Src/options.c 21 Aug 2006 20:59:26 -0000
@@ -687,7 +687,16 @@
setuid(getuid());
setgid(getgid());
#endif /* HAVE_SETUID */
-#ifndef JOB_CONTROL
+#ifdef JOB_CONTROL
+ } else if (!force && optno == MONITOR) {
+ if (opts[optno] == value)
+ return 0;
+ if (interact && (SHTTY != -1)) {
+ origpgrp = GETPGRP();
+ acquire_pgrp();
+ } else
+ return -1;
+#else
} else if(optno == MONITOR && value) {
return -1;
#endif /* not JOB_CONTROL */
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author