🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #7007

Some help with write(2) and errno.

#7007
From: Bernie Kirby
Date: Mon, 18 Mar 1991 17:28
61 lines
2053 bytes
I have some software that does a write(2) then if that fails sends a stop
signal to process so that the problem causing the write to fail can be
cleared up. The process is supposed to be then restarted with a 'kill
-CONT ...'.

The most usual cause for the write to fail (in this case) is that the file
sytem is full. However, once the process has been stopped and some more
space made available on the file system, and then restarted, the program
still believes that file system is full.  The write call appears to always
think that there is a problem.  Is there a way to tell the program that
the file system is no longer full? I cannot close and reopen the file.

I hope somebody can tell me what I'm missing.....

Bernie.

The code looks something like this:

#include <stdio.h>
#include <errno.h>
#include <pwd.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
extern char	*sys_errlist[];

/*
 * Write out some bytes.....
 * Stop and send mail if we run out of space etc etc...
 */
int
my_write(fd, buf, nbytes)
	int	fd;
	char	*buf;
	int	nbytes;
{
	int	n;
	int	not_written = 1;
	long	pos = tell(fd);

	do {
		if ((n = write(fd, buf, nbytes)) < 0) {
			perror("write:");

			kill(getpid(), SIGSTOP);

			/*
			 * We live again....
			 */

			if (lseek(fd, pos, SEEK_SET) < 0) {
				perror("lseek:");
				exit(1);
			}
			not_written++;
		} else 
			not_written = 0;
	} while (not_written);

	return(n);
}
Technical Details
Message-ID: <1955@brchh104.bnr.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request
From: bernie@eric.ecr.mu.oz.au (Bernie Kirby)
Newsgroups: comp.sys.sun
Subject: Some help with write(2) and errno.
Keywords: Miscellaneous
Message-ID: <1955@brchh104.bnr.ca>
Date: 18 Mar 91 17:28:00 GMT
Sender: news@brchh104.bnr.ca
Organization: Sun-Spots
Lines: 61
Approved: Sun-Spots@rice.edu
X-Original-Date: 5 Mar 91 06:57:02 GMT
X-Sun-Spots-Digest: Volume 10, Issue 57, message 12
X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu