[mw-devel] CVS Update at silver.sucs.org: mw

Finn Wilcox finnw at sucs.org
Thu Oct 31 22:42:30 GMT 2002


Are you sure this will catch actual errors (EOF, pipe vanished etc)?
I was under the impression these were flagged in the *read* set.
AFAIK the exception set is only used for urgent data on sockets.
Or are you planning to switch from pipes to sockets?

Finn

On Wed, 30 Oct 2002, Justin Mitchell wrote:

> CVSROOT:	/usr/local/src/cvs
> Module name:	mw
> Changes by:	arthur at silver.sucs.org	02/10/30 22:27:16
> 
> Modified files:
> 	src            : main.c 
> 
> Log message:
> 	Try actually catching any errors the idle select may offer
> 
> _______________________________________________
> Milliways Development mailing list - mw-devel at sucs.org - http://sucs.org/mailman/listinfo/mw-devel
> 
> -------------------------------------------------------------
> 
> Index: mw/src/main.c
> diff -c mw/src/main.c:1.224 mw/src/main.c:1.225
> *** mw/src/main.c:1.224	Tue Oct 29 19:17:47 2002
> --- mw/src/main.c	Wed Oct 30 22:27:16 2002
> ***************
> *** 1068,1074 ****
>   int idle(int fd, int millis)
>   {
>   	static int in_idle = 0;
> ! 	fd_set readfds;
>   	static struct timeval tmout;
>   	int nfds;
>   	static int fl=0;
> --- 1068,1074 ----
>   int idle(int fd, int millis)
>   {
>   	static int in_idle = 0;
> ! 	fd_set readfds, exceptfds;
>   	static struct timeval tmout;
>   	int nfds;
>   	static int fl=0;
> ***************
> *** 1077,1086 ****
> --- 1077,1089 ----
>   	in_idle++;
>   
>   	FD_ZERO(&readfds);
> + 	FD_ZERO(&exceptfds);
>   	FD_SET(incoming_pipe, &readfds);
> + 	FD_SET(incoming_pipe, &exceptfds);
>   	if (fd >= 0)
>   	{
>   		FD_SET(fd, &readfds);
> + 		FD_SET(fd, &exceptfds);
>   		fl = fcntl(fd, F_GETFL);
>   		fcntl(fd, F_SETFL, fl & ~O_NDELAY);
>   	}
> ***************
> *** 1091,1100 ****
>   		tmout.tv_usec = (millis % 1000) * 1000;
>   	}
>   
> ! 	nfds = alarm_select((fd>incoming_pipe)?(fd+1):(incoming_pipe+1), &readfds, NULL, NULL, (millis<0)?(NULL):(&tmout));
>   	select_error = errno;
>   	if (fd >= 0) fcntl(fd, F_SETFL, fl);
> ! 	if (nfds > 0 && FD_ISSET(incoming_pipe, &readfds)) handle_mesg();
>   	in_idle--;
>   
>   	errno = select_error;
> --- 1094,1114 ----
>   		tmout.tv_usec = (millis % 1000) * 1000;
>   	}
>   
> ! 	nfds = alarm_select((fd>incoming_pipe)?(fd+1):(incoming_pipe+1), &readfds, NULL, &exceptfds, (millis<0)?(NULL):(&tmout));
>   	select_error = errno;
>   	if (fd >= 0) fcntl(fd, F_SETFL, fl);
> ! 	if (nfds > 0) {
> ! 		if (FD_ISSET(incoming_pipe, &exceptfds)) {
> ! 			fprintf(stderr, "\nError reading incoming message pipe. panic.\n");
> ! 			return -1;
> ! 		}
> ! 		if (fd>=0 && FD_ISSET(fd, &exceptfds)) {
> ! 			fprintf(stderr, "\nError on input terminal, argh.\n");
> ! 			return -1;
> ! 		}
> ! 		if (FD_ISSET(incoming_pipe, &readfds)) 
> ! 		       handle_mesg();
> ! 	}
>   	in_idle--;
>   
>   	errno = select_error;
> 




More information about the mw-devel mailing list