!DSPAM:48276c5e89891804284693!
Index: daemon/lmsd.c
===================================================================
RCS file: /cvsroot/lms/daemon/lmsd.c,v
retrieving revision 1.36
diff -u -r1.36 lmsd.c
--- daemon/lmsd.c 4 Jan 2008 07:53:17 -0000 1.36
+++ daemon/lmsd.c 11 May 2008 21:26:50 -0000
@@ -41,6 +41,7 @@
int quit = 0, runall = 0, port = 0, dontfork = 0, ssl = 0;
char *db, *user, *passwd;
char host[255], dhost[255];
+char *pidfile = NULL;
char *command = NULL;
char *iopt = NULL;
struct sigaction sa, orig;
@@ -65,6 +66,7 @@
INSTANCE *instances;
int fval = 0, i = 0, reload = 0;
char *inst, *instance;
+ FILE *pidf;
#ifdef CONFIGFILE
Config *ini;
#endif
@@ -143,6 +145,11 @@
#ifdef DEBUG1
syslog(LOG_INFO, "DEBUG: [lmsd] Daemonize. Forked child %d.", fval);
#endif
+ if (pidfile != NULL && (pidf = fopen(pidfile, "w")) != NULL)
+ {
+ fprintf(pidf, "%d", fval);
+ fclose(pidf);
+ }
exit(0); // parent exits
}
}
@@ -420,6 +427,7 @@
{ "dbuser", 1, 0, 'u' },
{ "dbpass", 1, 0, 'p' },
{ "hostname", 1, 0, 'H' },
+ { "pidfile", 1, 0, 'P' },
{ "command", 2, 0, 'c' },
{ "reload", 0, 0, 'q' },
{ "reload-all", 0, 0, 'r' },
@@ -432,7 +440,7 @@
sscanf(REVISION, "$Id: lmsd.c,v %s", revision);
- while( (opt = getopt_long(argc, argv, "sqrfvi:h:p:d:u:H:c:", options, &option_index)) != -1 )
+ while( (opt = getopt_long(argc, argv, "sqrfvi:h:p:d:u:H:c:P:", options, &option_index)) != -1 )
{
switch(opt)
{
@@ -473,6 +481,9 @@
case 'c':
command = strdup(optarg);
break;
+ case 'P':
+ pidfile = strdup(optarg);
+ break;
default:
printf("LMS Daemon version 1.11-cvs (%s). Command line options:\n", revision);
printf(" --dbhost -h host[:port]\tdatabase host (default: 'localhost')\n");
@@ -481,6 +492,7 @@
printf(" --dbpass -p password\t\tdatabase password (default: '')\n");
printf(" --ssl -s\t\t\tuse SSL connection (default: disabled)\n");
printf(" --hostname -H daemon_host\thost name where runs daemon (default: `hostname`)\n");
+ printf(" --pidfile -P pid_file\t\tpidfile where daemon write pid (default: none)\n");
printf(" --command -c command\t\tshell command to run before database connecting\n\t\t\t\t(default: empty)\n");
printf(" --reload -q \t\t\tdo a reload and quit\n");
printf(" --reload-all -r \t\tdo a reload of all instances and quit\n");
!DSPAM:48276c5e89891804284693!