Check return values if write and unlink.
This commit is contained in:
parent
5fb7b2e12c
commit
13d94f240c
1 changed files with 4 additions and 4 deletions
|
@ -410,12 +410,12 @@ bool fgInitHome()
|
||||||
#else
|
#else
|
||||||
// POSIX, do open+unlink trick to the file is deleted on exit, even if we
|
// POSIX, do open+unlink trick to the file is deleted on exit, even if we
|
||||||
// crash or exit(-1)
|
// crash or exit(-1)
|
||||||
size_t len = snprintf(buf, 16, "%d", getpid());
|
ssize_t len = snprintf(buf, 16, "%d", getpid());
|
||||||
int fd = ::open(pidPath.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
|
int fd = ::open(pidPath.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0644);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
::write(fd, buf, len);
|
result = ::write(fd, buf, len) == len;
|
||||||
::unlink(pidPath.c_str()); // delete file when app quits
|
if( ::unlink(pidPath.c_str()) != 0 ) // delete file when app quits
|
||||||
result = true;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fgSetBool("/sim/fghome-readonly", false);
|
fgSetBool("/sim/fghome-readonly", false);
|
||||||
|
|
Loading…
Reference in a new issue