checking close's return value
The Beach Bum
jfh at rpp386.Dallas.TX.US
Mon Sep 26 08:16:01 AEST 1988
In article <3542 at ihlpe.ATT.COM> daryl at ihlpe.UUCP (Daryl Monge) writes:
>In article <1213 at unmvax.unm.edu> mike at 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 <fcntl.h>
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 at 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
More information about the Comp.unix.wizards
mailing list