pidfile patches from Diego Petteno

This commit is contained in:
Ron Pedde 2005-10-26 05:10:19 +00:00
parent 283261585d
commit 4c89c687a6
2 changed files with 12 additions and 3 deletions

View File

@ -98,4 +98,7 @@ blech (from the forums)
Phil Packer Phil Packer
* Patches for returning static playlists in order * Patches for returning static playlists in order
Diego Penneno
* Patches for multiple PID files to facilitate gentoo init scripts

View File

@ -188,6 +188,7 @@ void usage(char *program) {
printf(" -D <mod,mod..> Debug modules\n"); printf(" -D <mod,mod..> Debug modules\n");
printf(" -m Disable mDNS\n"); printf(" -m Disable mDNS\n");
printf(" -c <file> Use configfile specified\n"); printf(" -c <file> Use configfile specified\n");
printf(" -P <file> Write the PID ot specified file\n");
printf(" -f Run in foreground\n"); printf(" -f Run in foreground\n");
printf(" -y Yes, go ahead and run as non-root user\n"); printf(" -y Yes, go ahead and run as non-root user\n");
printf("\n\n"); printf("\n\n");
@ -345,6 +346,7 @@ int start_signal_handler(pthread_t *handler_tid) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int option; int option;
char *configfile=DEFAULT_CONFIGFILE; char *configfile=DEFAULT_CONFIGFILE;
char *pidfile=PIDFILE;
WSCONFIG ws_config; WSCONFIG ws_config;
WSHANDLE server; WSHANDLE server;
int foreground=0; int foreground=0;
@ -363,7 +365,7 @@ int main(int argc, char *argv[]) {
config.use_mdns=1; config.use_mdns=1;
err_debuglevel=1; err_debuglevel=1;
while((option=getopt(argc,argv,"D:d:c:mfrys")) != -1) { while((option=getopt(argc,argv,"D:d:c:P:mfrys")) != -1) {
switch(option) { switch(option) {
case 'd': case 'd':
err_debuglevel=atoi(optarg); err_debuglevel=atoi(optarg);
@ -386,6 +388,10 @@ int main(int argc, char *argv[]) {
config.use_mdns=0; config.use_mdns=0;
break; break;
case 'P':
pidfile=optarg;
break;
case 'r': case 'r':
reload=1; reload=1;
break; break;
@ -442,8 +448,8 @@ int main(int argc, char *argv[]) {
/* open the pidfile, so it can be written once we detach */ /* open the pidfile, so it can be written once we detach */
if((!foreground) && (!force_non_root)) { if((!foreground) && (!force_non_root)) {
if(-1 == (pid_fd = open(PIDFILE,O_CREAT | O_WRONLY | O_TRUNC, 0644))) if(-1 == (pid_fd = open(pidfile,O_CREAT | O_WRONLY | O_TRUNC, 0644)))
DPRINTF(E_FATAL,L_MAIN,"Error opening pidfile (%s): %s\n",PIDFILE,strerror(errno)); DPRINTF(E_FATAL,L_MAIN,"Error opening pidfile (%s): %s\n",pidfile,strerror(errno));
if(0 == (pid_fp = fdopen(pid_fd, "w"))) if(0 == (pid_fp = fdopen(pid_fd, "w")))
DPRINTF(E_FATAL,L_MAIN,"fdopen: %s\n",strerror(errno)); DPRINTF(E_FATAL,L_MAIN,"fdopen: %s\n",strerror(errno));