mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 14:29:47 +00:00
2004-12-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* pid_output.c: (pid_output_lock) Eliminate static function, and just use the #ifdef to decide which version of the function to include. This eliminates a compilation problem with gcc4. And fix the non-fcntl version so that it actually compiles. Exit with status 1 instead of -1 on error.
This commit is contained in:
parent
fa40f65874
commit
202d08cab9
@ -1,3 +1,11 @@
|
|||||||
|
2004-12-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
|
* pid_output.c: (pid_output_lock) Eliminate static function, and just
|
||||||
|
use the #ifdef to decide which version of the function to include.
|
||||||
|
This eliminates a compilation problem with gcc4. And fix the
|
||||||
|
non-fcntl version so that it actually compiles. Exit with
|
||||||
|
status 1 instead of -1 on error.
|
||||||
|
|
||||||
2004-12-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
2004-12-15 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
|
||||||
|
|
||||||
* sigevent.c: (trap_default_signals) Ignore SIGPIPE instead of exiting.
|
* sigevent.c: (trap_default_signals) Ignore SIGPIPE instead of exiting.
|
||||||
|
@ -25,13 +25,14 @@
|
|||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_FCNTL
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
pid_output (const char *path)
|
pid_output (const char *path)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_FCNTL
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
mask_t oldumask;
|
mode_t oldumask;
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
|
||||||
@ -42,20 +43,20 @@ pid_output (const char *path)
|
|||||||
fprintf (fp, "%d\n", (int) pid);
|
fprintf (fp, "%d\n", (int) pid);
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
umask(oldumask);
|
umask(oldumask);
|
||||||
return -1;
|
return pid;
|
||||||
}
|
}
|
||||||
|
/* XXX Why do we continue instead of exiting? This seems incompatible
|
||||||
|
with the behavior of the fcntl version below. */
|
||||||
|
zlog_warn("Can't fopen pid lock file %s (%s), continuing",
|
||||||
|
path, safe_strerror(errno));
|
||||||
umask(oldumask);
|
umask(oldumask);
|
||||||
return pid;
|
return -1;
|
||||||
#else
|
|
||||||
static pid_t pid_output_lock (const char *);
|
|
||||||
|
|
||||||
return pid_output_lock(path);
|
|
||||||
#endif /* HAVE_FCNTL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FCNTL
|
#else /* HAVE_FCNTL */
|
||||||
static pid_t
|
|
||||||
pid_output_lock (const char *path)
|
pid_t
|
||||||
|
pid_output (const char *path)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
int fd;
|
int fd;
|
||||||
@ -68,12 +69,12 @@ pid_output_lock (const char *path)
|
|||||||
|
|
||||||
oldumask = umask(0777 & ~LOGFILE_MASK);
|
oldumask = umask(0777 & ~LOGFILE_MASK);
|
||||||
fd = open (path, O_RDWR | O_CREAT, LOGFILE_MASK);
|
fd = open (path, O_RDWR | O_CREAT, LOGFILE_MASK);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
zlog_err( "Can't creat pid lock file %s (%s), exit",
|
zlog_err("Can't create pid lock file %s (%s), exiting",
|
||||||
path, safe_strerror(errno));
|
path, safe_strerror(errno));
|
||||||
umask(oldumask);
|
umask(oldumask);
|
||||||
exit (-1);
|
exit(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -87,8 +88,8 @@ pid_output_lock (const char *path)
|
|||||||
|
|
||||||
if (fcntl(fd, F_SETLK, &lock) < 0)
|
if (fcntl(fd, F_SETLK, &lock) < 0)
|
||||||
{
|
{
|
||||||
zlog_err("Could not lock pid_file %s, exit", path);
|
zlog_err("Could not lock pid_file %s, exiting", path);
|
||||||
exit (-1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (buf, "%d\n", (int) pid);
|
sprintf (buf, "%d\n", (int) pid);
|
||||||
@ -102,4 +103,5 @@ pid_output_lock (const char *path)
|
|||||||
}
|
}
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_FCNTL */
|
#endif /* HAVE_FCNTL */
|
||||||
|
Loading…
Reference in New Issue
Block a user