protected override void DisposeInternal() { if (_fd != -1) { // note that the orders of operations is important here, we first unlink the file // we are supposed to be the only one using it, so Linux would be ready to delete it // and hopefully when we close it, won't waste any time trying to sync the memory state // to disk just to discard it if (DeleteOnClose) { Syscall.unlink(FileName.FullPath); // explicitly ignoring the result here, there isn't // much we can do to recover from being unable to delete it } Syscall.close(_fd); _fd = -1; } }