termio(7) and read(2) problem!

Michael "Ford" Ditto ditto at cbmvax.UUCP
Thu Feb 9 13:33:34 AEST 1989


In article <10652 at stb.UUCP> michael at stb.UUCP (Michael) writes:
>Does anyone know how to turn ON NDELAY for an already open file?

Use fcntl(2):

	int oldmode = fcntl(fd, F_GETFL);
	if (oldmode == -1)
	    perror("fcntl(F_GETFL)");
	else
	    if (fcntl(fd, F_SETFL, oldmode|O_NDELAY) == -1)
		perror("fcntl(F_SETFL)");

Or, if you're not a fan of error checking:

	fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NDELAY);

-- 
					-=] Ford [=-

"The number of Unix installations	(In Real Life:  Mike Ditto)
has grown to 10, with more expected."	ford at kenobi.cts.com
- The Unix Programmer's Manual,		...!sdcsvax!crash!elgar!ford
  2nd Edition, June, 1972.		ditto at cbmvax.commodore.com



More information about the Unix-pc.general mailing list