From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3397 invoked from network); 13 Feb 2001 13:13:52 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Feb 2001 13:13:52 -0000 Received: (qmail 897 invoked by alias); 13 Feb 2001 13:13:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13462 Received: (qmail 883 invoked from network); 13 Feb 2001 13:13:43 -0000 Date: Tue, 13 Feb 2001 14:13:40 +0100 (MET) Message-Id: <200102131313.OAA13149@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: zpty -t I found a report about zpty -t not working properly on the debian bug list. For example: % zpty z zsh % zpty -w z exit % zpty -r z % zpty -t z && echo running printed `running'. Below is my n+1'th attempt at making this better, not relying on read_poll() in checkptycmd() (because that uses select() which succeeds even if the process has terminated and there isn't really anything to read). Dunno if this is really any better, but at least it solves the problem above. What do the Cygwin folks say? Bye Sven Index: Src/Modules/zpty.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v retrieving revision 1.21 diff -u -r1.21 zpty.c --- Src/Modules/zpty.c 2001/01/16 13:44:20 1.21 +++ Src/Modules/zpty.c 2001/02/13 13:12:00 @@ -430,13 +430,19 @@ static void checkptycmd(Ptycmd cmd) { - if (cmd->read != -1) + char c; + int r; + + if (cmd->read != -1 || cmd->fin) return; - if (!read_poll(cmd->fd, &cmd->read, 0) && - kill(cmd->pid, 0) < 0) { - cmd->fin = 1; - zclose(cmd->fd); + if ((r = read(cmd->fd, &c, 1)) < 0) { + if (kill(cmd->pid, 0) < 0) { + cmd->fin = 1; + zclose(cmd->fd); + } + return; } + if (r) cmd->read = (int) c; } static int -- Sven Wischnowsky wischnow@informatik.hu-berlin.de