Path: utzoo!mnetor!uunet!cos!hadron!decuac!felix!zemon From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.ultrix Subject: Submission for comp-unix-ultrix Message-ID: <20506@felix.UUCP> Date: 4 Feb 88 19:26:53 GMT References: <20344@felix.UUCP> Sender: zemon@felix.UUCP Reply-To: chris@mimsy.UUCP (Chris Torek) Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 37 Approved: zemon@felix.UUCP Reply-Path: In article <20344@felix.UUCP> jdp@adiron.UUCP (Powell) writes: -I don't remember this bug being reported before so here goes: - -ULTRIX 1.2 is semi-4.2BSD compatible but 4.2BSD will not exhibit -this bug: The bug is in the program that attempts to demonstrate the bug, not in the kernel. (jdp seems to know that, but his posting may be unclear to others.) -readfd = (1 << 3); -if (select(getdtablesize(),&readfd,0,0,0) < 0) - fprintf(stderr,"Error in select %d\n",errno); -else - fprintf(stderr,"select ok\n"); -The second time and probably all remaining times that select is called, -it will fail with the error number corresponding to invalid file descriptor. -Replace the getdtablesize() with the expression (8 * sizeof readfd) for -portability. s/portability/correctness/: `8*sizeof(readfd)' assumes that the type `char' is eight bits wide. Better yet, borrow the fd_set type and FD_xxx macros from a 4.3BSD (which is what DEC should have done). -...getdtablesize() and NOFILE under standard ULTRIX 1.2 are greater -than 32 (namely 64). The readfd parameter is a 32-bit value so it -can never tell select() to poll file descriptors 32 - 63 but -apparently select() is looking for advice about all 64 descriptors -because you told it to. Shame on you :-) Right. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris