From 49839f356f493d0de1b719c8c3bfdee4713c0728 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 Sep 2005 16:57:08 +0000 Subject: r10513: Reduce some use of pstring. The main reason some parts of the code still use pstring is next_token() now. (This used to be commit a5b88bcd420eb7ae42283293541519e142be36e3) --- source4/lib/cmdline/popt_common.h | 1 - source4/lib/pidfile.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/cmdline/popt_common.h b/source4/lib/cmdline/popt_common.h index 28676de56b..785a50ae70 100644 --- a/source4/lib/cmdline/popt_common.h +++ b/source4/lib/cmdline/popt_common.h @@ -22,7 +22,6 @@ #define _POPT_COMMON_H #include "popt.h" -#include "pstring.h" /* Common popt structures */ extern struct poptOption popt_common_samba[]; diff --git a/source4/lib/pidfile.c b/source4/lib/pidfile.c index b1866ee6af..54d2c81d2e 100644 --- a/source4/lib/pidfile.c +++ b/source4/lib/pidfile.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "pstring.h" #include "system/filesys.h" #ifndef O_NONBLOCK @@ -35,11 +34,13 @@ pid_t pidfile_pid(const char *name) int fd; char pidstr[20]; uint_t ret; - pstring pidFile; + char *pidFile; - slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); + asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name); fd = open(pidFile, O_NONBLOCK | O_RDONLY, 0644); + SAFE_FREE(pidFile); + if (fd == -1) { return 0; } @@ -75,10 +76,10 @@ void pidfile_create(const char *name) { int fd; char buf[20]; - pstring pidFile; + char *pidFile; pid_t pid; - slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); + asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name); pid = pidfile_pid(name); if (pid != 0) { @@ -107,5 +108,7 @@ void pidfile_create(const char *name) pidFile, strerror(errno))); exit(1); } + /* Leave pid file open & locked for the duration... */ + SAFE_FREE(pidFile); } -- cgit