diff -ru metalog-0.6/AUTHORS metalog-0.6.1/AUTHORS --- metalog-0.6/AUTHORS 2001-06-25 17:08:40.000000000 -0400 +++ metalog-0.6.1/AUTHORS 2002-01-26 07:16:44.000000000 -0500 @@ -1 +1,2 @@ Frank DENIS "Jedi/Sector One" +Leo Lipelis - tiny patch to allow /var/run/metalog.pid diff -ru metalog-0.6/ChangeLog metalog-0.6.1/ChangeLog --- metalog-0.6/ChangeLog 2001-07-09 10:27:55.000000000 -0400 +++ metalog-0.6.1/ChangeLog 2002-01-26 07:16:44.000000000 -0500 @@ -1,3 +1,5 @@ +* Gentoo Patch : + Add --pidfile option to allow pid file creation. * Version 0.6 : Use strtoq if strtoull isn't available. Read /dev/klog when klogctl() isn't implemented. diff -ru metalog-0.6/src/metalog.c metalog-0.6.1/src/metalog.c --- metalog-0.6/src/metalog.c 2001-07-09 10:23:16.000000000 -0400 +++ metalog-0.6.1/src/metalog.c 2002-01-26 09:36:54.000000000 -0500 @@ -868,6 +868,8 @@ static RETSIGTYPE sigkchld(int sig) { + fprintf(stderr, "Unlinking pid file: %s\n", pid_file); + unlink(pid_file); fprintf(stderr, "Process [%u] died with signal [%d]\n", (unsigned int) getpid(), sig); exit(EXIT_FAILURE); @@ -974,6 +976,7 @@ int fodder; int option_index = 0; + pid_file = NULL; while ((fodder = getopt_long(argc, argv, GETOPT_OPTIONS, long_options, &option_index)) != -1) { switch (fodder) { @@ -995,6 +998,13 @@ case 's' : synchronous = (sig_atomic_t) 1; break; + case 'p' : + /* this is needed because argv will get nuked */ + pid_file = (char *) malloc(strlen(optarg) + 1); + if (pid_file != NULL) { + strcpy(pid_file, optarg); + } + break; default : fprintf(stderr, "Unknown option\n"); exit(EXIT_FAILURE); @@ -1010,6 +1020,16 @@ } } +static void writePidFile(const char *const pid_file) +{ + FILE *f; + f = fopen(pid_file, "wb"); + if (f) { + fprintf(f, "%u\n", (u_int) getpid()); + fclose(f); + } +} + int main(int argc, char *argv[]) { int sockets[2]; @@ -1025,6 +1045,10 @@ } dodaemonize(); setsignals(); + /* write MASTER pid to /var/run/metalog.pid */ + if (pid_file) { + writePidFile(pid_file); + } clearargs(argv); setprogname(PROGNAME_MASTER); if (getDataSources(sockets) < 0) { diff -ru metalog-0.6/src/metalog_p.h metalog-0.6.1/src/metalog_p.h --- metalog-0.6/src/metalog_p.h 2001-07-09 10:17:06.000000000 -0400 +++ metalog-0.6.1/src/metalog_p.h 2002-01-26 07:16:44.000000000 -0500 @@ -2,9 +2,9 @@ #define __METALOG_P_H__ 1 #ifdef HAVE_KLOGCTL -# define GETOPT_OPTIONS "Bc:hs" +# define GETOPT_OPTIONS "Bc:hsp:" #else -# define GETOPT_OPTIONS "Bhs" +# define GETOPT_OPTIONS "Bhsp:" #endif static struct option long_options[] = { @@ -14,6 +14,7 @@ #endif { "help", 0, NULL, 'h' }, { "synchronous", 0, NULL, 's' }, + { "pidfile", 1, NULL, 'p' }, { NULL, 0, NULL, 0 } }; @@ -27,5 +28,6 @@ static pid_t command_child; static sig_atomic_t synchronous; static signed char daemonize; +static char *pid_file; #endif