Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!brl-adm!brl-smoke!smoke!moss@BRL.ARPA From: moss@BRL.ARPA (Gary S. Moss (SLCBR-VLD-V)) Newsgroups: net.lang.c Subject: Re: C prgram needed - read with timeout Message-ID: <3133@brl-smoke.ARPA> Date: Mon, 18-Aug-86 10:54:54 EDT Article-I.D.: brl-smok.3133 Posted: Mon Aug 18 10:54:54 1986 Date-Received: Wed, 20-Aug-86 05:09:31 EDT Sender: news@brl-smoke.ARPA Lines: 38 Tony, When I use fcntl() to set O_NDELAY, I save the file status flags on program startup, and restore them before exiting. Here are some subroutines out of my library that should do the job, assuming that HP's UNIX is pretty standard... #include #include static int fileStatus[_NFILE]; int reset_Fil_Stat(); /* s a v e _ F i l _ S t a t ( ) Save file status flags for 'fd'. */ save_Fil_Stat( fd ) int fd; { return fileStatus[fd] = fcntl( fd, F_GETFL, 0 ); } /* r e s e t _ F i l _ S t a t ( ) Restore file status flags for file desc. 'fd' to what they were the last time save_Fil_Stat(fd) was called. */ reset_Fil_Stat( fd ) int fd; { return fcntl( fd, F_SETFL, fileStatus[fd] ); } /* s e t _ O _ N D E L A Y ( ) Set non-blocking read on 'fd'. */ set_O_NDELAY( fd ) int fd; { return fcntl( fd, F_SETFL, O_NDELAY ); } -moss