Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!killer!vector!rpp386!jfh
From: jfh@rpp386.Dallas.TX.US (The Beach Bum)
Newsgroups: comp.unix.wizards
Subject: Re: checking close's return value
Message-ID: <7109@rpp386.Dallas.TX.US>
Date: 25 Sep 88 22:16:01 GMT
References: <20981@watmath.waterloo.edu> <1988Sep20.230150.7574@utzoo.uucp> <1213@unmvax.unm.edu> <3542@ihlpe.ATT.COM>
Reply-To: jfh@rpp386.Dallas.TX.US (The Beach Bum)
Organization: HASA, "S" Division
Lines: 34

In article <3542@ihlpe.ATT.COM> daryl@ihlpe.UUCP (Daryl Monge) writes:
>In article <1213@unmvax.unm.edu> mike@turing.unm.edu (Michael I. Bushnell) writes:
>>UNIX does *not* guarantee that hardware related errors
>>will get reflected on write. ...
>> ... The actual
>>disk write may take place hours after the write(2) system call
>
>So true.  I would like it if close(2) would insure all blocks were
>successfully written to disk before it returned.
>(Possibly by an fcntl(2) option if every one doesn't want this?)

this can be handled by open(...,|O_SYNCW);

the following routine will cause the given file descriptor to have
the O_SYNCW bit set:

#include 

int	setsync (fd)
int	fd;
{
	int	flags;

	if ((flags = fcntl (fd, F_GETFL, 0)) == -1)
		return (-1);

	flags |= O_SYNCW;
	return (fcntl (fd, F_SETFL, flags));
}
-- 
John F. Haugh II (jfh@rpp386.Dallas.TX.US)                   HASA, "S" Division

      "Why waste negative entropy on comments, when you could use the same
                   entropy to create bugs instead?" -- Steve Elias