Unblocking filedescriptor(s)

Root Boy Jim rbj at uunet.UU.NET
Sun Jan 27 17:25:43 AEST 1991


In article <1991Jan25.235221.21868 at odin.diku.dk> cthulhu at freja.diku.dk (Stefan Krabbe) writes:
>I am programming in a 4.3BSD environment...
> In a program I am currently writing I make a filedescriptor unblocking
>this way:
>             fcntl(filedescriptor, F_SETFL, FNDELAY);

What you really want to do to make it unblocking is something like:

	flags = fcntl(fd, F_GETFL, 0);		/* get old flags */
	flags |= FNDELAY;			/* add no delay */
	fcntl(fd, F_SETFL, flags);		/* set new flags */

Your code sets the flags to FNDELAY, and clears any existing flags.
My code adds FNDELAY to the existing flag set.
	
> But what do I do if I want it make it blocking again? 

I think you can take it from here.
-- 

	Root Boy Jim Cottrell <rbj at uunet.uu.net>
	Close the gap of the dark year in between



More information about the Comp.unix.wizards mailing list