From owner-freebsd-questions Mon Oct 12 19:35:16 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA09287 for freebsd-questions-outgoing; Mon, 12 Oct 1998 19:35:16 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from smtp2.globalserve.net (smtp2.globalserve.net [209.90.128.7]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA09256 for ; Mon, 12 Oct 1998 19:35:01 -0700 (PDT) (envelope-from geoffr@globalserve.net) Received: from globalserve.net (dialin1938.toronto.globalserve.net [209.90.137.159]) by smtp2.globalserve.net (8.9.1/8.9.1) with ESMTP id WAA09222; Mon, 12 Oct 1998 22:30:19 -0400 (EDT) Message-ID: <3622B97D.C04E46C2@globalserve.net> Date: Mon, 12 Oct 1998 22:22:53 -0400 From: Geoffrey Robinson X-Mailer: Mozilla 4.03 [en] (Win95; U) MIME-Version: 1.0 To: Doug White , questions@FreeBSD.ORG Subject: Re: Interrupted System Calls Infinite Loop References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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