From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4311 invoked by alias); 11 Jun 2017 18:20:55 -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: 41269 Received: (qmail 742 invoked from network); 11 Jun 2017 18:20:55 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f176.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.176):SA:0(0.0/5.0):. Processed in 1.912532 secs); 11 Jun 2017 18:20:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.176 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=g9BZ0G94RMtM/6mkkknPt35f03AhGpsNrz0mM04qkfg=; b=ZGs+MnZZi2lK2aKh7DTp1/GobhPfwzGvhSlNaIws+QtPdT7Y9rxvLVfJfbpK43Vla0 B+ILMxDNEbiZNuy232aNmS16NV54tmtkQp4RWmrgeay0ZJA7JgpwhudtaX15oYdwtpbQ +qOHDZq3ftXzQlUN3rVdZbF9OfyJ06zNQ4hG/T/7YRYDR+XMbriWTdf4PWmlELjfyO9L m8ZxUMQt5Z2IHKEuYQwEuadkfoOQefZunkaX7Nge+8+ogMyg0XRwlGXZZ+n4I/+GsWDB PxYXxECdWltZSPBvmSlrEhpTiis51kSJM9wPdYURcPv1cbi80rZh6stqOEvqyFC7jAYA 49YQ== X-Gm-Message-State: AKS2vOxH9Rno3vcVqqRMLvJCGXGaJCmNt9rJSjtntqLt7MA+tCEbEoqf 2q/e6JU8Td9Y+Mhc X-Received: by 10.28.142.15 with SMTP id q15mr5568834wmd.28.1497205247870; Sun, 11 Jun 2017 11:20:47 -0700 (PDT) Date: Sun, 11 Jun 2017 19:20:45 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: [PATCH] avoid closed stdin() in zle widgets Message-ID: <20170611182045.GA5318@chaz.gmail.com> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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));