* Properly fixed libutil; we should not use O_TRUNC before having exclusive
access to the file. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34281 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f2505b1583
commit
648aeae3bc
@ -112,9 +112,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
|
||||
* PID file will be truncated again in pidfile_write(), so
|
||||
* pidfile_write() can be called multiple times.
|
||||
*/
|
||||
fd = open(pfh->pf_path,
|
||||
O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
|
||||
|
||||
fd = open(pfh->pf_path, O_WRONLY | O_CREAT | O_NONBLOCK, mode);
|
||||
if (fd >= 0) {
|
||||
struct flock lock;
|
||||
lock.l_type = F_WRLCK;
|
||||
@ -122,7 +120,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
|
||||
lock.l_start = 0;
|
||||
lock.l_len = 0;
|
||||
|
||||
if (fcntl(F_SETLK, &lock) == -1) {
|
||||
if (fcntl(fd, F_SETLK, &lock) == -1) {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
@ -138,6 +136,8 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ftruncate(fd, 0);
|
||||
|
||||
/*
|
||||
* Remember file information, so in pidfile_write() we are sure we write
|
||||
* to the proper descriptor.
|
||||
|
Loading…
Reference in New Issue
Block a user