Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!Tappan@BBNG.ARPA
From: Tappan@BBNG.ARPA@sri-unix.UUCP
Newsgroups: net.unix-wizards
Subject: Re: how do you time-out on a read?
Message-ID: <3518@sri-arpa.UUCP>
Date: Wed, 27-Jul-83 16:32:08 EDT
Article-I.D.: sri-arpa.3518
Posted: Wed Jul 27 16:32:08 1983
Date-Received: Fri, 29-Jul-83 06:41:41 EDT
Lines: 26

From:  Dan Tappan 

It seems to me that setjmp/longjmp won't work for timing out a read
if you don't want to lose data. There's a potential race condition.
eg. if you have code like

	nread = 0;
	if (!setjmp(env))
	{
	   alarm(XXX);
	   nread = read(..)  /* (1) */;
	   alarm(0);
	   }

	if (nread > 0) { /* process data */ }


if the alarm goes off in the middle of statement (1), after the read
completes but before 'nread' gets set, then that buffer of data
will be lost.

However I'm not familiar with the UNIX kernal signal handling code. Is it
guaranteed that that statement won't be interrupted?

Dan
-------