Author: jra Date: 2006-11-02 09:37:52 +0000 (Thu, 02 Nov 2006) New Revision: 19533
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19533 Log: Add a suffix to the program name if this is a process with a non-default configuration file name. Jeremy. Modified: branches/SAMBA_3_0/source/Makefile.in branches/SAMBA_3_0/source/lib/pidfile.c branches/SAMBA_3_0_23/source/Makefile.in branches/SAMBA_3_0_23/source/lib/pidfile.c branches/SAMBA_3_0_24/source/Makefile.in branches/SAMBA_3_0_24/source/lib/pidfile.c Changeset: Modified: branches/SAMBA_3_0/source/Makefile.in =================================================================== --- branches/SAMBA_3_0/source/Makefile.in 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0/source/Makefile.in 2006-11-02 09:37:52 UTC (rev 19533) @@ -965,6 +965,10 @@ echo "$(CC) $(FLAGS) $(PATH_FLAGS) $(PICFLAG) -c $(srcdir)/dynconfig.c -o $@" 1>&2;\ $(CC) $(FLAGS) $(PATH_FLAGS) $(PICFLAG) -c $(srcdir)/dynconfig.c -o $@ >/dev/null 2>&1 +lib/pidfile.o: lib/pidfile.c + @echo Compiling $*.c + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) $(PICFLAG) -c $(srcdir)/lib/pidfile.c -o $@ + lib/version.o: lib/version.c include/version.h @echo Compiling $*.c @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) $(PICFLAG) -c $(srcdir)/lib/version.c -o $@ Modified: branches/SAMBA_3_0/source/lib/pidfile.c =================================================================== --- branches/SAMBA_3_0/source/lib/pidfile.c 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0/source/lib/pidfile.c 2006-11-02 09:37:52 UTC (rev 19533) @@ -78,13 +78,24 @@ } /* create a pid file in the pid directory. open it and leave it locked */ -void pidfile_create(const char *name) +void pidfile_create(const char *program_name) { int fd; char buf[20]; + char *short_configfile; + pstring name; pstring pidFile; pid_t pid; + /* Add a suffix to the program name if this is a process with a + * none default configuration file name. */ + if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) { + strncpy( name, program_name, sizeof( name)-1); + } else { + short_configfile = strrchr( dyn_CONFIGFILE, '/'); + slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1); + } + slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); pid = pidfile_pid(name); Modified: branches/SAMBA_3_0_23/source/Makefile.in =================================================================== --- branches/SAMBA_3_0_23/source/Makefile.in 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0_23/source/Makefile.in 2006-11-02 09:37:52 UTC (rev 19533) @@ -872,6 +872,17 @@ @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $(srcdir)/dynconfig.c -o $@ @BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e '[EMAIL PROTECTED]@$$%.o%'` $@ +lib/pidfile.o: lib/pidfile.c + @echo Compiling $*.c + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $(srcdir)/lib/pidfile.c -o $@ + +lib/[EMAIL PROTECTED]@: lib/pidfile.c + @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ + dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi + @echo Compiling $*.c with @PICFLAGS@ + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $(srcdir)/lib/pidfile.c -o $@ [EMAIL PROTECTED]@ -mv `echo $@ | sed -e 's%^.*/%%g' -e '[EMAIL PROTECTED]@$$%.o%'` $@ + lib/version.o: lib/version.c include/version.h @echo Compiling $*.c @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $(srcdir)/lib/version.c -o $@ Modified: branches/SAMBA_3_0_23/source/lib/pidfile.c =================================================================== --- branches/SAMBA_3_0_23/source/lib/pidfile.c 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0_23/source/lib/pidfile.c 2006-11-02 09:37:52 UTC (rev 19533) @@ -78,13 +78,24 @@ } /* create a pid file in the pid directory. open it and leave it locked */ -void pidfile_create(const char *name) +void pidfile_create(const char *program_name) { int fd; char buf[20]; + char *short_configfile; + pstring name; pstring pidFile; pid_t pid; + /* Add a suffix to the program name if this is a process with a + * none default configuration file name. */ + if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) { + strncpy( name, program_name, sizeof( name)-1); + } else { + short_configfile = strrchr( dyn_CONFIGFILE, '/'); + slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1); + } + slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); pid = pidfile_pid(name); Modified: branches/SAMBA_3_0_24/source/Makefile.in =================================================================== --- branches/SAMBA_3_0_24/source/Makefile.in 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0_24/source/Makefile.in 2006-11-02 09:37:52 UTC (rev 19533) @@ -873,6 +873,17 @@ @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $(srcdir)/dynconfig.c -o $@ @BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e '[EMAIL PROTECTED]@$$%.o%'` $@ +lib/pidfile.o: lib/pidfile.c + @echo Compiling $*.c + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $(srcdir)/lib/pidfile.c -o $@ + +lib/[EMAIL PROTECTED]@: lib/pidfile.c + @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ + dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi + @echo Compiling $*.c with @PICFLAGS@ + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $(srcdir)/lib/pidfile.c -o $@ [EMAIL PROTECTED]@ -mv `echo $@ | sed -e 's%^.*/%%g' -e '[EMAIL PROTECTED]@$$%.o%'` $@ + lib/version.o: lib/version.c include/version.h @echo Compiling $*.c @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PIE_CFLAGS@ -c $(srcdir)/lib/version.c -o $@ Modified: branches/SAMBA_3_0_24/source/lib/pidfile.c =================================================================== --- branches/SAMBA_3_0_24/source/lib/pidfile.c 2006-11-02 00:32:42 UTC (rev 19532) +++ branches/SAMBA_3_0_24/source/lib/pidfile.c 2006-11-02 09:37:52 UTC (rev 19533) @@ -78,13 +78,24 @@ } /* create a pid file in the pid directory. open it and leave it locked */ -void pidfile_create(const char *name) +void pidfile_create(const char *program_name) { int fd; char buf[20]; + char *short_configfile; + pstring name; pstring pidFile; pid_t pid; + /* Add a suffix to the program name if this is a process with a + * none default configuration file name. */ + if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) { + strncpy( name, program_name, sizeof( name)-1); + } else { + short_configfile = strrchr( dyn_CONFIGFILE, '/'); + slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1); + } + slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); pid = pidfile_pid(name);