From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5836 invoked by alias); 11 Aug 2015 04:06:42 -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: 36092 Received: (qmail 11180 invoked from network); 11 Aug 2015 04:06:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=CC58AiKBtKit3oG+npoMFwy+CpXcbB4NSUANyg18FZ4=; b=UoPanojDjnVdzXw1tYxx5UTAEcb2Rlyn5JVlLU6P+msrDnJtQ+bw2w7BOVFt8otwNw 0I/lowMZrOzzi9iBMrz1/NwUDZCOAG3Dcc8w8lMYeZfAxmvriv3VXYlVz1LLNERgZCq+ I+EwlDifxCM9gz22HJitsjNEKwHGAx0CtJjbD/AUh+xQOpcBXKO7EncYunCg7bwnNodM ZwUdTqu6S1BfZqcRiRMxU/Q27rrvIqK1dl/01UX76/qQh8rmVaU7GDpjOewlaDTD6gqS aUGWNXTFXw3sKn63rPfA5+Jy2TbbUkQu2DISeCFyhEX3UfPa0ENvHGuiQ1i/0bGrzWuC WP7A== X-Gm-Message-State: ALoCoQljWT17MztZLonM0rK87/LO6XmNN1vvgVzVjKLPue1H4k5wFIo//1VTG6+4t5JIbaZlDNO8 X-Received: by 10.182.79.232 with SMTP id m8mr8636719obx.25.1439265997779; Mon, 10 Aug 2015 21:06:37 -0700 (PDT) From: Bart Schaefer Message-Id: <150810210634.ZM26862@torch.brasslantern.com> Date: Mon, 10 Aug 2015 21:06:34 -0700 In-Reply-To: Comments: In reply to Mathias Fredriksson "Re: Deadlock when receiving kill-signal from child process" (Aug 11, 1:53am) References: <150803085228.ZM24837@torch.brasslantern.com> <150803135818.ZM24977@torch.brasslantern.com> <150804235400.ZM9958@torch.brasslantern.com> <150805085258.ZM17673@torch.brasslantern.com> <150805115249.ZM7158@torch.brasslantern.com> <150805132014.ZM7746@torch.brasslantern.com> <150805220656.ZM18545@torch.brasslantern.com> <150806085451.ZM402@torch.brasslantern.com> <150806223906.ZM17762@torch.brasslantern.com> <150810123445.ZM1612@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Running commands in a zpty worker MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 11, 1:53am, Mathias Fredriksson wrote: } } I went back to my original use case where I'm running commands in a } zpty worker and notifying the original zsh pid that the work is done } (previously through WINCH, now tested with USR1). Incidentally you might try using ZLE handler functions for this instead of signals. You'd need a FIFO for the zpty command to write to and the ZLE handler to listen on. Which is really kind of silly given that there's already a descriptor. With this patch you can do e.g. typeset -A ptys watcher() { local line; zpty -r $ptys[$1] line; etc with $line } zpty firstPTY some command ... ptys[$REPLY]=firstPTY zle -F $REPLY watcher Just be careful to remove the handler before the slave side of the pty is closed (e.g., worker exits) or you may end up with a runaway handler. diff --git a/Doc/Zsh/mod_zpty.yo b/Doc/Zsh/mod_zpty.yo index 340f983..44b375a 100644 --- a/Doc/Zsh/mod_zpty.yo +++ b/Doc/Zsh/mod_zpty.yo @@ -18,6 +18,15 @@ characters are echoed. With the tt(-b) option, input to and output from the pseudo-terminal are made non-blocking. + +The shell parameter tt(REPLY) is set to the file descriptor assigned to +the master side of the pseudo-terminal. This allows the terminal to be +monitored with ZLE descriptor handlers (see ifzman(zmanref(zshzle))\ +ifnzman(noderef(Zle Builtins))) or manipulated with tt(sysread) and +tt(syswrite) (see ifzman(THE ZSH/SYSTEM MODULE in zmanref(zshmodules))\ +ifnzman(noderef(The zsh/system Module))). em(Warning): Use of tt(sysread) +and tt(syswrite) is em(not) recommended, use tt(zpty -r) and tt(zpty -w) +unless you know exactly what you are doing. ) item(tt(zpty) tt(-d) [ var(name) ... ])( The second form, with the tt(-d) option, is used to delete commands diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 7b6130c..12e42b5 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -463,6 +463,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) #endif errno == EINTR)); + setiparam("REPLY", master); + return 0; }