zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@frontiernet.net>
To: schaefer@candle.brasslantern.com (Bart Schaefer)
Cc: zsh-workers@math.gatech.edu (Zsh hacking and development),
	Ingo.Wilken@Informatik.Uni-Oldenburg.DE
Subject: Re: Completion bug introduced in 3.0.3
Date: Wed, 2 Jul 1997 02:55:04 -0400 (EDT)	[thread overview]
Message-ID: <199707020655.CAA11774@hzoli.home> (raw)
In-Reply-To: <970701231018.ZM8001@candle.brasslantern.com> from Bart Schaefer at "Jul 1, 97 11:10:18 pm"

> On Jul 2, 12:51am, Zoltan Hidvegi wrote:
> } Subject: Re: Completion bug introduced in 3.0.3
> }
> } > Another thing:  I use a TCL script that sets its stdout stream to
> } > non-blocking.  This somehow affects zsh, as all interactive commands
> } > started after the TCL script (like "ftp" or "more") immediately terminate
> 
> I meant to mention this before ...
> 
> It's an extremely bad idea for any program to set a tty device for non-
> blocking I/O.  This doesn't "somehow affect zsh," it affects the modes
> of the file descriptor associated with the tty; which happens to be a
> dup of the one zsh continues using for future processes, and therefore
> it affects those processes as well.

Perhaps I have a different tclsh, which resets the mode when it exits.  But
this can be tested with this little C program (nonblock.c):

#include <unistd.h>
#include <fcntl.h>

int
main(int argc, char *argv[])
{
    fcntl(0, F_SETFL, O_NONBLOCK);
    exit(0);
}

It sets stdin, but on a terminal this is the same as stdout.  Bash, ksh
and pdksh does seem to reset stdin on startup and before each prompt if
-s (shinstdin in zsh) is set, zsh doesn't.  POSIX says that blocking
input should be set on shell startup, but it does not seems to be
necessary to reset blocking mode after every application.  But blocking
mode should always be set when stdin is used, not only when shinstdin is
set.  Bash violates this:

nonblock; bash -c 'read foo; echo $foo'

does not set blocking read.  AT&T ksh93 does set blocking read here.
pdksh too, but pdksh always sets blocking mode, regardless of the use of
stdin.

Here is the relevant part of the standard (from www.rdg.opengroup.org):

    The standard input will be used only if one of the following is true: 

      o The -s option is specified. 

      o The -c option is not specified and no operands are specified. 

      o The script executes one or more commands that require input from
        standard input (such as a read command that does not redirect its
        input). 

    [...]

    If the standard input to sh is a FIFO or terminal device and is set to
    non-blocking reads, then sh will enable blocking reads on standard
    input. This will remain in effect when the command completes.  (This
    concerns an instance of sh that has been invoked, probably by a
    C-language program, with standard input that has been opened using the
    O_NONBLOCK flag; see open() in the XSH specification. If the shell did
    not reset this flag, it would immediately terminate because no input
    data would be available yet and that would be considered the same as
    end-of-file.)

I think that the AT&T ksh behaviour is the most conforming and most
logical one.

Zoltan


  reply	other threads:[~1997-07-02  7:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-02  3:48 Ingo Wilken
1997-07-02  4:41 ` Geoff Wing
1997-07-02  5:43   ` Bart Schaefer
1997-07-02  4:51 ` Zoltan Hidvegi
1997-07-02  6:10   ` Bart Schaefer
1997-07-02  6:55     ` Zoltan Hidvegi [this message]
1997-07-04  0:53   ` Ingo Wilken
1997-07-02  5:12 ` Bart Schaefer

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=199707020655.CAA11774@hzoli.home \
    --to=hzoli@frontiernet.net \
    --cc=Ingo.Wilken@Informatik.Uni-Oldenburg.DE \
    --cc=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /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).