Discussion:
write behavior after unlink
(too old to reply)
Toby Hsieh
2008-10-23 22:57:34 UTC
Permalink
From my understanding of the spec, if you creat a file, unlink it, and
then call write referencing this file descriptor, it should return -1;
however, for some reason, file.write appears to be allowing the write.
Can someone confirm that -1 is returned when you call write() in this
scenario?
Chris Thompson
2008-10-24 23:18:20 UTC
Permalink
The way I read it, unlink will wait to delete the file until all open
FileDescriptors to it are closed. Since creat also opens the file, and
close was never called, that file shouldn't be deleted yet. (The call to
unlink should cause all new creat/opens on that file to block until it's
been deleted, though. There's a surprising amount of tricky
synchronization involved, and I don't have that coded yet, but I think
it's kinda like the soda machine problem).
Post by Toby Hsieh
From my understanding of the spec, if you creat a file, unlink it, and
then call write referencing this file descriptor, it should return -1;
however, for some reason, file.write appears to be allowing the write.
Can someone confirm that -1 is returned when you call write() in this
scenario?
Loading...