Date: Mon, 12 Oct 1998 22:22:53 -0400 From: Geoffrey Robinson <geoffr@globalserve.net> To: Doug White <dwhite@resnet.uoregon.edu>, questions@FreeBSD.ORG Subject: Re: Interrupted System Calls Infinite Loop Message-ID: <3622B97D.C04E46C2@globalserve.net> References: <Pine.BSF.4.03.9810121323460.25080-100000@resnet.uoregon.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Doug White wrote: > > On Sun, 11 Oct 1998, Geoffrey Robinson wrote: > > > A friend of mine is working on a CGI that runs as many as 6 times a second > > and reads and writes to several files each time it runs. One file in > > particular that is opened with fopen() as read only is failing with errno > > EINTR. I looked up interrupted system calls in _Advanced Programming in the > > UNIX Environment_ by W. Richard Stevens who suggest handling the error by > > simply retrying the system call repeatedly until it succeeds. > > I'd be intrigued to know why the syscall is being interrupted. The > underlying open() is dying. Are you using any wacky open flags? Here is the function where the problem is occurring. Turns out that the same error is occurring in a similar function in another program that runs many times a second. The error happens on the fread(), we tried logging errno when this happened and found that it is EINTR. We thought the problem may be related to the number of times the CGI runs (sometimes with bursts over 15 times a second) and tried locking the record so only one program could read at a time but it made no difference. Other than the number of times it runs I can't see anything wrong with it myself. Could it be exceeding some resource limit? Global varibles FILE *fp2; struct size_record sizerec; int get_size(void) { int error_handle; int num_tries = 100; int count = 0; fp2 = fopen(sizefile,"r"); if(fp2 == NULL) { error("Unable to open sizes file\n"); error_handle = fseek(fp2,0,SEEK_SET); if(error_handle == -1) { error("Unable to seek in Sizes File.\n"); } /* lock_sizes(0); */ error_handle = fread(&sizerec,1,sizeof(struct size_record),fp2); if(error_handle == 0) { error("Read Error in Sizes File.\n"); } /* unlock_sizes(0); */ fclose(fp2); return(0); } - Geoff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3622B97D.C04E46C2>