zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: process substitution and Ctrl-C
Date: Thu, 19 Aug 2010 21:37:17 +0100	[thread overview]
Message-ID: <20100819213717.5b5a7466@pws-pc> (raw)
In-Reply-To: <100819083237.ZM26692@torch.brasslantern.com>

On Thu, 19 Aug 2010 08:32:37 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> If I try
> 
>     echo >>(cat; sleep 100)
> 
> then the shell is effectively frozen until "sleep 100" finishes, because
> "echo" is already gone and the process substitution is not interruptible,
> so nothing is paying attention to ^C or ^Z etc.

(This should have gone to zsh-workers ages ago but still hasn't.)

This is a separate problem.  It's not so much that the echo has gone as
that there are no processes in the tty process group to get the signal,
because the substitution is treated as asynchronous for the purposes of
job handling.  (In fact, I've decided I don't understand what
"asynchronous" means in this case, either.  We seem to have spent
chunks of the last twenty years making process substitution less and
less like an asynchronous process; first we started waiting for it to
finish, now we're passing signals to it.)

Any reactions to the following patch?  This makes the substitution
process always get the same signal as the rest of the command line.  If
that's an external process that would be interrupted, so you wouldn't
see the freeze, but even there without the patch the "sleep" carries
merrily on --- similar to Vincent's case.

The alternative is to make it synchronous only if the current job is
running within the shell.  I no longer really have any idea what the
intention is.

I'm assuming the other use of >(...), when not part of a redirection,
want identical treatment to whatever happens here.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.181
diff -p -u -r1.181 exec.c
--- Src/exec.c	15 Jul 2010 18:44:13 -0000	1.181
+++ Src/exec.c	19 Aug 2010 20:26:24 -0000
@@ -3828,7 +3828,7 @@ getproc(char *cmd, char **eptr)
 	zerr("can't open %s: %e", pnam, errno);
 	_exit(1);
     }
-    entersubsh(ESUB_ASYNC|ESUB_PGRP);
+    entersubsh(ESUB_PGRP);
     redup(fd, out);
 #else /* PATH_DEV_FD */
     int pipes[2];
@@ -3855,7 +3855,7 @@ getproc(char *cmd, char **eptr)
 	}
 	return pnam;
     }
-    entersubsh(ESUB_ASYNC|ESUB_PGRP);
+    entersubsh(ESUB_PGRP);
     redup(pipes[out], out);
     closem(FDT_UNUSED);   /* this closes pipes[!out] as well */
 #endif /* PATH_DEV_FD */
@@ -3905,7 +3905,7 @@ getpipe(char *cmd, int nullexec)
 	    addproc(pid, NULL, 1, &bgtime);
 	return pipes[!out];
     }
-    entersubsh(ESUB_ASYNC|ESUB_PGRP);
+    entersubsh(ESUB_PGRP);
     redup(pipes[out], out);
     closem(FDT_UNUSED);	/* this closes pipes[!out] as well */
     cmdpush(CS_CMDSUBST);

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2010-08-19 20:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-19 12:41 Vincent Lefevre
2010-08-19 13:07 ` Peter Stephenson
2010-08-19 17:15   ` Peter Stephenson
2010-08-19 20:18     ` Peter Stephenson
2010-08-19 15:32 ` Bart Schaefer
2010-08-19 20:37   ` Peter Stephenson [this message]
2010-08-19 21:17   ` Vincent Lefevre
2010-08-20  8:19     ` Bart Schaefer
2010-08-20 11:52       ` Vincent Lefevre
2010-08-20 15:24         ` Bart Schaefer
2010-08-21  0:04           ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100819213717.5b5a7466@pws-pc \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).