Help! My fd's are incrementing by themselves!!

George W. Leach reggie at dinsdale.paradyne.com
Tue May 8 02:40:24 AEST 1990


In article <1990May4.125945.19579 at uunet!unhd> rg at 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



More information about the Comp.unix.wizards mailing list