mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 02:37:21 +00:00
2004-11-25 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* pid_output.c: (pid_output_lock) Fix 2 bugs: when locking, should set l_whence to SEEK_SET, not SEEK_END. And after writing new pid to file, must ftruncate to eliminate any extraneous bytes left over from the last time a pid was written.
This commit is contained in:
parent
ad4d974d06
commit
e5879ca1d8
@ -1,3 +1,10 @@
|
|||||||
|
2004-11-25 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
|
* pid_output.c: (pid_output_lock) Fix 2 bugs: when locking, should
|
||||||
|
set l_whence to SEEK_SET, not SEEK_END. And after writing new
|
||||||
|
pid to file, must ftruncate to eliminate any extraneous bytes left
|
||||||
|
over from the last time a pid was written.
|
||||||
|
|
||||||
2004-11-24 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
2004-11-24 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
* zassert.h: New header file to declare a quagga-specific assert macro.
|
* zassert.h: New header file to declare a quagga-specific assert macro.
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
#include <zebra.h>
|
#include <zebra.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
#include "version.h"
|
||||||
pid_t pid_output_lock(const char *);
|
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
pid_output (const char *path)
|
pid_output (const char *path)
|
||||||
@ -77,11 +76,13 @@ pid_output_lock (const char *path)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
size_t pidsize;
|
||||||
|
|
||||||
umask(oldumask);
|
umask(oldumask);
|
||||||
memset (&lock, 0, sizeof(lock));
|
memset (&lock, 0, sizeof(lock));
|
||||||
|
|
||||||
lock.l_type = F_WRLCK;
|
lock.l_type = F_WRLCK;
|
||||||
lock.l_whence = SEEK_END;
|
lock.l_whence = SEEK_SET;
|
||||||
|
|
||||||
if (fcntl(fd, F_SETLK, &lock) < 0)
|
if (fcntl(fd, F_SETLK, &lock) < 0)
|
||||||
{
|
{
|
||||||
@ -90,7 +91,13 @@ pid_output_lock (const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprintf (buf, "%d\n", (int) pid);
|
sprintf (buf, "%d\n", (int) pid);
|
||||||
tmp = write (fd, buf, strlen (buf));
|
pidsize = strlen(buf);
|
||||||
|
if ((tmp = write (fd, buf, pidsize)) != (int)pidsize)
|
||||||
|
zlog_err("Could not write pid %d to pid_file %s, rc was %d: %s",
|
||||||
|
(int)pid,path,tmp,safe_strerror(errno));
|
||||||
|
else if (ftruncate(fd, pidsize) < 0)
|
||||||
|
zlog_err("Could not truncate pid_file %s to %u bytes: %s",
|
||||||
|
path,(u_int)pidsize,safe_strerror(errno));
|
||||||
}
|
}
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user