add -F option for writing pid file. Patch from misc@mandriva.org #70

This commit is contained in:
misc
2009-08-15 21:52:49 +00:00
committed by Erik Ekman
parent 2482a42d01
commit 7efdd01ae2
5 changed files with 58 additions and 12 deletions

View File

@@ -26,6 +26,7 @@
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#ifdef WINDOWS32
#include <winsock2.h>
@@ -39,6 +40,7 @@
#include <err.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <syslog.h>
#endif
#ifdef HAVE_SETCON
@@ -182,6 +184,24 @@ do_setcon(char *context)
#endif
}
void
do_pidfile(char *pidfile)
{
#ifndef WINDOWS32
FILE *file;
if ((file = fopen(pidfile, "w")) == NULL) {
syslog(LOG_ERR, "Cannot write pidfile to %s, exiting", pidfile);
err(1, "do_pidfile: Can not write pidfile to %s", pidfile);
} else {
fprintf(file, "%d\n", (int)getpid());
fclose(file);
}
#else
fprintf(stderr, "Windows version does not support pid file\n");
#endif
}
void
do_detach()
{