From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5893 invoked from network); 25 May 2000 09:44:46 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 25 May 2000 09:44:46 -0000 Received: (qmail 12935 invoked by alias); 25 May 2000 09:44:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11567 Received: (qmail 12921 invoked from network); 25 May 2000 09:44:30 -0000 Date: Thu, 25 May 2000 10:44:01 +0100 From: Peter Stephenson Subject: PATCH: FD_CLOEXEC To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FV400JGT0DC95@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT I was thinking about the command substitution problem and keeping file descriptors open when I checked up on the use of the close-on-exec flag in zftp.c, which is the only place it's used (could we do with some more?) I noticed I was using it with pointers instead of integers; goodness knows why, except there's no type checking on that argument. I confirmed by experiment on Solaris that it wants the actual integer (easy to test, since FD_CLOEXEC is 1 and pointers are even). I developed zftp under AIX, so it's just possible something funny is going on there. Maybe Oliver could check it at least compiles? Index: Src/Modules/zftp.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/zftp.c,v retrieving revision 1.3 diff -u -r1.3 zftp.c --- Src/Modules/zftp.c 2000/05/09 17:49:30 1.3 +++ Src/Modules/zftp.c 2000/05/25 09:41:43 @@ -1303,8 +1303,7 @@ #endif #if defined(F_SETFD) && defined(FD_CLOEXEC) /* If the shell execs a program, we don't want this fd left open. */ - len = FD_CLOEXEC; - fcntl(zfsess->dfd, F_SETFD, &len); + fcntl(zfsess->dfd, F_SETFD, FD_CLOEXEC); #endif return 0; @@ -1988,8 +1987,7 @@ #if defined(F_SETFD) && defined(FD_CLOEXEC) /* If the shell execs a program, we don't want this fd left open. */ - len = FD_CLOEXEC; - fcntl(zfsess->cfd, F_SETFD, &len); + fcntl(zfsess->cfd, F_SETFD, FD_CLOEXEC); #endif len = sizeof(zfsess->sock); @@ -2057,8 +2055,7 @@ DPUTS(zfstatfd == -1, "zfstatfd not created"); #if defined(F_SETFD) && defined(FD_CLOEXEC) /* If the shell execs a program, we don't want this fd left open. */ - len = FD_CLOEXEC; - fcntl(zfstatfd, F_SETFD, &len); + fcntl(zfstatfd, F_SETFD, FD_CLOEXEC); #endif unlink(fname); }