From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id BAA28660 for ; Wed, 8 May 1996 01:58:09 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id LAA14220; Tue, 7 May 1996 11:45:27 -0400 (EDT) Resent-Date: Tue, 7 May 1996 11:45:27 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199605071545.RAA16858@bolyai.cs.elte.hu> Subject: Re: fdtable To: pws@ifh.de (Peter Stephenson) Date: Tue, 7 May 1996 17:45:13 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu (Zsh workers list) In-Reply-To: <199605071452.QAA20774@hydra.ifh.de> from Peter Stephenson at "May 7, 96 04:52:40 pm" Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL16 (25)] MIME-Version: 1.0 Content-Type: application/pgp; format=text; x-action=sign Content-Transfer-Encoding: 7bit Resent-Message-ID: <"PibwQ2.0.4U3.M0tZn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/996 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- > I wrote: > > Shouldn't fdtable[] be `signed char'? (Yes.) > > Zefram just pointed out the simplest thing to do was simply to define > signed to nothing if it isn't supported. Here's the third attempt. > I'd be obliged if somebody using a K&R compiler could have a go at it. > (I did try it by altering the cached value to `no'.) I think the most simple and most portable solution is not using negative values here. This patch does this. If one did not apply the patch in article 987 there will be a rejected patch which can be probably be ignored. Zoltan *** Src/exec.c 1996/05/07 15:30:12 2.19 --- Src/exec.c 1996/05/07 15:33:17 *************** *** 1321,1327 **** read(synch[0], &dummy, 1); close(synch[0]); #ifdef HAVE_DEV_FD ! closem(-1); #endif if (how & Z_ASYNC) { lastpid = (long) pid; --- 1321,1327 ---- read(synch[0], &dummy, 1); close(synch[0]); #ifdef HAVE_DEV_FD ! closem(2); #endif if (how & Z_ASYNC) { lastpid = (long) pid; *************** *** 1520,1527 **** int i; for (i = 10; i < OPEN_MAX; i++) ! if (fdtable[i] < 0) ! fdtable[i]--; #endif if (subsh_close >= 0) zclose(subsh_close); --- 1520,1527 ---- int i; for (i = 10; i < OPEN_MAX; i++) ! if (fdtable[i] > 1) ! fdtable[i]++; #endif if (subsh_close >= 0) zclose(subsh_close); *************** *** 1529,1536 **** execshfunc(cmd, (Shfunc) hn); #ifdef HAVE_DEV_FD for (i = 10; i < OPEN_MAX; i++) ! if (fdtable[i] < 0) ! if (++(fdtable[i]) >= -1) zclose(i); #endif } else { --- 1529,1536 ---- execshfunc(cmd, (Shfunc) hn); #ifdef HAVE_DEV_FD for (i = 10; i < OPEN_MAX; i++) ! if (fdtable[i] > 1) ! if (--(fdtable[i]) <= 2) zclose(i); #endif } else { *************** *** 1539,1545 **** closem(1); lastval = execbuiltin(args, (Builtin) hn); #ifdef HAVE_DEV_FD ! closem(-1); #endif if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) && lastval && !subsh) { fprintf(stderr, "zsh: exit %ld\n", (long)lastval); --- 1539,1545 ---- closem(1); lastval = execbuiltin(args, (Builtin) hn); #ifdef HAVE_DEV_FD ! closem(2); #endif if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) && lastval && !subsh) { fprintf(stderr, "zsh: exit %ld\n", (long)lastval); *************** *** 2121,2127 **** if (zfork()) { sprintf(pnam, "/dev/fd/%d", pipes[!out]); zclose(pipes[out]); ! fdtable[pipes[!out]] = -1; #endif popheap(); return pnam; --- 2121,2127 ---- if (zfork()) { sprintf(pnam, "/dev/fd/%d", pipes[!out]); zclose(pipes[out]); ! fdtable[pipes[!out]] = 2; #endif popheap(); return pnam; *** Src/globals.h 1996/05/04 23:26:18 2.11 --- Src/globals.h 1996/05/06 14:08:57 *************** *** 390,398 **** EXTERN int sourcelevel; /* The table of file descriptors. A table element is zero if the * ! * corresponding fd is not used by the shell. It is negative if * ! * the fd is used by a <(...) or >(...) substitution and 1 if it * ! * is an internal file descriptor which must be closed before * * executing an external command. The first ten elements of the * * table is not used. A table element is set by movefd and cleard * * by zclose. */ --- 390,398 ---- EXTERN int sourcelevel; /* The table of file descriptors. A table element is zero if the * ! * corresponding fd is not used by the shell. It is greater than * ! * 1 if the fd is used by a <(...) or >(...) substitution and 1 if * ! * it is an internal file descriptor which must be closed before * * executing an external command. The first ten elements of the * * table is not used. A table element is set by movefd and cleard * * by zclose. */ -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv iQCVAwUBMY9v/AupSCiLN749AQEGMAP9FMqGOKjszp94S3TVY4PqlMLvyhWwhI1q 3+qPM1AMgxow0nZuovdemz76yfCVK5WRtacBWwpUgKo96+b5OIJnAGhxOELVEULn QmpKTP5zIgYsKNY2/D3ouDdePINcMfLfCcwI06n8SEbjhxKRiCxSmFkJMT+rtlPU EH9mSo787g8= =sPnE -----END PGP SIGNATURE-----