Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] avoid closed stdin() in zle widgets
- X-seq: zsh-workers 41269
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] avoid closed stdin() in zle widgets
- Date: Sun, 11 Jun 2017 19:20:45 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=g9BZ0G94RMtM/6mkkknPt35f03AhGpsNrz0mM04qkfg=; b=Ad7g8yT6FrJbWJuLi2fQcgAw0J0DA4INiwE0or/CsVQRD7e2wCEeef6ROYLbFlpULu 9mF+o6Vj2JjzS1YsGdInsH0I0wIV5TTEUKORgtw79ptClfzxToE3TCwwC1XU2dRw5edk 9rlHMqi9lMAkUsf9uS9jpj5rx95GLHaPLYHWcoO9SNny4ShyISnZd1YcZPGdxk9gAdMF QYZ/h3LixZSzdbihpkmlk9IU9LgrTKy0UsB5jHWXniPCVfE6ADxFX3RVK2/428rRNycj YoLFydWTEQieboKbqEaaXgXd7U+5VvNnFCrqOaCPINB7gKky22ILwQUsUSknb2U5Z9sO vvGw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello,
in zle widgets, stdin currently appears to be closed. That's
generally not a good idea to close fds 0, 1, 2 as many commands
are confused when the files they open suddenly become their
stdin/stdout/stderr because the first free fd is 0/1/2.
See
https://unix.stackexchange.com/q/370475
for instance.
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 81687c7..0e26da3 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -2012,7 +2012,8 @@ enditem()
Attribute flags that transform the final value (tt(-L), tt(-R), tt(-Z),
tt(-l), tt(-u)) are only applied to the expanded value at the point
of a parameter expansion expression using `tt($)'. They are not applied
-when a parameter is retrieved internally by the shell for any purpose.
+when a parameter is retrieved internally by the shell for any purpose.
+They have no effect on array or associative array parameters.
The following attribute flags may be specified:
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 6c271b5..be2b062 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1485,6 +1485,13 @@ execzlefunc(Thingy func, char **args, int set_bindk)
int inuse = w->flags & WIDGET_INUSE;
w->flags |= WIDGET_INUSE;
+ if (osi > 0) {
+ /*
+ * Many commands don't like having a closed stdin, open on
+ * /dev/null instead
+ */
+ open("/dev/null", O_RDWR | O_NOCTTY); /* ignore failure */
+ }
if (*args) {
largs = newlinklist();
addlinknode(largs, dupstring(w->u.fnnam));
Messages sorted by:
Reverse Date,
Date,
Thread,
Author