Author: Lars Mueller Subject: Allow multiple Samba configurations on one machine to use the same PIDDIR Bugzilla: 48237, bugzilla.Samba.org #2049 Index: source/Makefile.in =================================================================== --- source/Makefile.in (revision 3810) +++ source/Makefile.in (working copy) @@ -782,6 +782,16 @@ @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) @PICFLAGS@ -c $< -o $*.@PICSUFFIX@ @BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.@PICSUFFIX@$$%.o%'` $@ +lib/pidfile.o: lib/pidfile.c + @echo Compiling $*.c + @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS1) -c $< -o $@ + +lib/pidfile.@PICSUFFIX@: 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_FLAGS1) @PICFLAGS@ -c $< -o $*.@PICSUFFIX@ + lib/version.o: lib/version.c include/version.h @echo Compiling $*.c @$(CC) -I. -I$(srcdir) $(FLAGS) $(PATH_FLAGS) -c $< -o $@ Index: source/lib/pidfile.c =================================================================== --- source/lib/pidfile.c (revision 3810) +++ source/lib/pidfile.c (working copy) @@ -76,13 +76,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);