Potrzeba mi było do skryptów startowych dla lmsd, żeby tworzył on przy starcie plik pid z procesem, przesyłam patcha z poprawką, może komuś się też przyda Pozdrawiam
Index: daemon/configure =================================================================== RCS file: /home/cvsroot/lms/daemon/configure,v retrieving revision 1.19 diff -u -r1.19 configure --- daemon/configure 22 Sep 2005 09:32:13 -0000 1.19 +++ daemon/configure 23 Nov 2006 23:55:13 -0000 @@ -4,6 +4,7 @@ prefix="/usr/local" incdir="/usr/include" libdir="/usr/lib" +pidfile="/var/run/lmsd.pid" with_mysql=yes
# Create config.status file @@ -74,6 +75,9 @@ -ini=* | -ini=* | -inifile=* | --inifile=* ) inifile="$ac_optarg" ;; + -pidfile=* | --pidfile=* | -pid=* | --pid=* ) + pidfile="$ac_optarg" + ;; -help | --help ) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. @@ -86,11 +90,12 @@ --with-pgsql enables use of PostgreSQL database (disabled) --with-mysql enables use of MySQL database (enabled) --prefix=PREFIX sets program and modules install location - (/usr/local), modules goes to PREFIX/lms/lib and main - program to PREFIX/lms/bin + (/usr/local), modules goes to PREFIX/lib/lms and main + program to PREFIX/bin --libdir=DIR sets location of database library (/usr/lib) --incdir=DIR sets location of database include files (/usr/include) --inifile=FILE configuration file - disables online configuration + --pidfile=FILE pid file (/var/run/lmsd.pid) EOF exit 0 ;; @@ -184,6 +189,10 @@ echo " no" fi
+echo -n "PID File..." +FLAGS="$FLAGS -DPIDFILE=\"$pidfile\"" +echo " $pidfile" + # Set install directories echo -n "Daemon install directory..." start=`pwd` @@ -194,7 +203,7 @@ fi prefix=`pwd` cd $start -LMS_BIN_DIR="$prefix/lms/bin" +LMS_BIN_DIR="$prefix/bin" echo " $LMS_BIN_DIR"
echo -n "Modules install directory..." @@ -206,7 +215,7 @@ fi prefix=`pwd` cd $start -LMS_LIB_DIR="$prefix/lms/lib" +LMS_LIB_DIR="$prefix/lib/lms" echo " $LMS_LIB_DIR"
# Create makefiles Index: daemon/lmsd.c =================================================================== RCS file: /home/cvsroot/lms/daemon/lmsd.c,v retrieving revision 1.29 diff -u -r1.29 lmsd.c --- daemon/lmsd.c 14 Jun 2006 06:19:45 -0000 1.29 +++ daemon/lmsd.c 23 Nov 2006 23:55:21 -0000 @@ -42,6 +42,7 @@ char host[255], dhost[255]; char *command = NULL; char *iopt = NULL; +char *pidfile = PIDFILE; struct sigaction sa, orig;
static char **Argv = NULL; @@ -64,6 +65,7 @@ INSTANCE *instances; int fval = 0, i = 0, reload = 0, i_no = 0; char *inst, *instance; + FILE *fpid; #ifdef CONFIGFILE Config *ini; #endif @@ -135,6 +137,9 @@ setsid(); break; default: + fpid = fopen(pidfile, "w"); + fprintf(fpid, "%d\n", fval); + fclose(fpid); #ifdef DEBUG1 syslog(LOG_INFO, "DEBUG: [lmsd] Daemonize. Forked child %d.", fval); #endif @@ -413,6 +418,7 @@ { "foreground", 0, 0, 'f' }, { "instance", 2, 0, 'i' }, { "version", 0, 0, 'v' }, + { "pidfile", 1, 0, 'P' }, { 0, 0, 0, 0 } }; @@ -456,6 +462,9 @@ case 'c': command = strdup(optarg); break; + case 'P': + pidfile = strdup(optarg); + break;\ default: printf("LMS Daemon version 1.9-cvs (%s). Command line options:\n", revision); printf(" --dbhost -h host[:port]\tdatabase host (default: 'localhost')\n"); @@ -464,6 +473,7 @@ printf(" --dbpass -p password\t\tdatabase password (default: '')\n"); printf(" --hostname -H daemon_host\thost name where runs daemon (default: `hostname`)\n"); printf(" --command -c command\t\tshell command to run before database connecting\n\t\t\t\t(default: empty)\n"); + printf(" --pid -P pidfile\t\tpid file (default: %s)\n", PIDFILE); 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"); printf(" --foreground -f \t\trun in foreground (don't fork)\n");