Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!pdn!dinsdale!reggie From: reggie@dinsdale.paradyne.com (George W. Leach) Newsgroups: comp.unix.wizards Subject: Re: Help! My fd's are incrementing by themselves!! Message-ID: <1990May7.164024.2271@pdn.paradyne.com> Date: 7 May 90 16:40:24 GMT References: <1990May4.125945.19579@uunet!unhd> Sender: usenet@pdn.paradyne.com (0000-USENET News Administrator(0000)) Reply-To: reggie@dinsdale.paradyne.com (George W. Leach) Distribution: comp Organization: AT&T Suncoast Division, Largo FL Lines: 23 In article <1990May4.125945.19579@uunet!unhd> rg@unhd.unh.edu.UUCP (Roger Gonzalez ) writes: >if ((fd = open(unix_path, O_RDONLY)) < 0) { > perror("unix-open"); > return(ERROR); >} >if ((gfd = w_open("unix", worm_path, WRITEMODE) < 0) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ gfd is *ALWAYS* assigned the value 1 because the relational operator has higher precedence than the assignment operator. This means you NEVER close the actual file descriptor which is not saved in gfd. Use the parens as in your first open. George George W. Leach AT&T Paradyne (uunet|att)!pdn!reggie Mail stop LG-133 Phone: 1-813-530-2376 P.O. Box 2826 FAX: 1-813-530-8224 Largo, FL 34649-2826 USA