From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2711 invoked from network); 10 May 2000 04:49:12 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 May 2000 04:49:12 -0000 Received: (qmail 13010 invoked by alias); 10 May 2000 04:49:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11288 Received: (qmail 12985 invoked from network); 10 May 2000 04:49:02 -0000 From: "Bart Schaefer" Message-Id: <1000510044838.ZM2434@candle.brasslantern.com> Date: Wed, 10 May 2000 04:48:38 +0000 In-Reply-To: Comments: In reply to Tanaka Akira "closing stdin (Re: _make suppress error on OpenBSD.)" (May 10, 4:34am) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Tanaka Akira , zsh-workers@sunsite.auc.dk Subject: Re: closing stdin (Re: _make suppress error on OpenBSD.) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 10, 4:34am, Tanaka Akira wrote: } Subject: closing stdin (Re: _make suppress error on OpenBSD.) } } > coulee% make awk: i/o error occurred while closing /dev/stdin } } This problem is caused by the one true awk behavior. (OpenBSD comes } with the one true awk.) The one true awk closes all file descriptors } which should be opened when exit and complain if it causes an error. } [...] } } However, we can suppress the error by modifying each awk invocation, } but I think that completion system should redirect stdin from } /dev/null instead of closing it. It's a little more complex than this. Descriptor 0 is being closed by movefd(0) which is called from zle_main() before executing any user-defined widget, completion or otherwise. This explains why it doesn't work to invoke e.g. vim from a widget function. This has some odd side effects, including that assorted opens for things like shared library loading and directory scans for path searching can end up using FD 0 temporarily (look at strace output). (Memory mapping of autoloaded functions also sometimes gets FD 0 but immediately movefd()s it elsewhere.) It makes more sense to me from the standpoint of the shell's internals to simply close FD 0 rather than reopen it on /dev/null. On the other hand, I've long forgotten (if I ever knew) why the stdin of ZLE functions is closed. (Zefram?) It's trivial to reopen it again: function vi-vi-buffer() { local tmp=${TMPPREFIX}${$}vi print -R - $BUFFER >| $tmp vi $tmp