On Sat, Feb 7, 2009 at 12:39 AM, Clark Cox <clarkc...@gmail.com> wrote:
> Even if you delete the file from the filesystem, you are just deleting
> the mapping from that particular filename to the file's actual data.
> The actual "file" still there until the last process with an open
> handle closes it, so open()'ing a file will guarantee that it exists
> until you close() it, or your process terminates.

Well no, that's not true. If it were, the warning would be fairly
pointless. In normal operation, yes, a file will be kept around until
you're done with it. But think of a network filesystem where the
server goes away, or a USB drive where the user pulls the plug.

If you had a file open on such a filesystem through more normal means,
your calls to read() would simply begin to return errors, which you
could then deal with.

But there is no mechanism for returning errors for memory-mapped
files. What happens when you start trying to read from a memory mapped
file which has disappeared is that the system sends your process a
SIGSEGV signal, and your process disappears too.

Thus the warning: if a file disappears while you have it memory
mapped, and you try to access it, you will crash.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to