diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-03-24 20:17:08 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-03-24 21:55:40 +0100 |
commit | c0288e0612187ecbfc4a81d071fd504ea8737b7a (patch) | |
tree | d9928183d4eeca7c9aa55e4aabb91465fb72f09a /lib/util | |
parent | 55bd27935fe0bf31945d0137a1673499e7fcb1ad (diff) | |
download | samba-c0288e0612187ecbfc4a81d071fd504ea8737b7a.tar.gz samba-c0288e0612187ecbfc4a81d071fd504ea8737b7a.tar.bz2 samba-c0288e0612187ecbfc4a81d071fd504ea8737b7a.zip |
lib/util: Remove obsolete sys_getpid() and sys_fork().
The performance of these is minimal (these days) and they can return
invalid results when used as part of applications that do not use
sys_fork().
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Mar 24 21:55:41 CET 2012 on sn-devel-104
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/become_daemon.c | 2 | ||||
-rw-r--r-- | lib/util/fault.c | 2 | ||||
-rw-r--r-- | lib/util/samba_util.h | 10 | ||||
-rw-r--r-- | lib/util/system.c | 31 |
4 files changed, 2 insertions, 43 deletions
diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c index 4c1d29e5a7..92a75862bd 100644 --- a/lib/util/become_daemon.c +++ b/lib/util/become_daemon.c @@ -75,7 +75,7 @@ _PUBLIC_ void close_low_fds(bool stdin_too, bool stdout_too, bool stderr_too) _PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout) { if (do_fork) { - if (sys_fork()) { + if (fork()) { _exit(0); } } diff --git a/lib/util/fault.c b/lib/util/fault.c index b3527bb22e..d0b34e540b 100644 --- a/lib/util/fault.c +++ b/lib/util/fault.c @@ -70,7 +70,7 @@ static void fault_report(int sig) counter++; DEBUGSEP(0); - DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),SAMBA_VERSION_STRING)); + DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),SAMBA_VERSION_STRING)); DEBUG(0,("\nPlease read the Trouble-Shooting section of the Samba HOWTO\n")); DEBUGSEP(0); diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index f989231102..6096722d17 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -113,16 +113,6 @@ void CatchChild(void); **/ void CatchChildLeaveStatus(void); -/** - * Wrapper for fork used to invalid pid cache. - **/ -_PUBLIC_ pid_t sys_fork(void); - -/** - * Wrapper for getpid. Ensures we only do a system call *once*. - **/ -_PUBLIC_ pid_t sys_getpid(void); - struct sockaddr; _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa, diff --git a/lib/util/system.c b/lib/util/system.c index f34fabd292..558aa5bc12 100644 --- a/lib/util/system.c +++ b/lib/util/system.c @@ -40,37 +40,6 @@ */ -/************************************************************************** - Wrapper for fork. Ensures we clear our pid cache. -****************************************************************************/ - -static pid_t mypid = (pid_t)-1; - -_PUBLIC_ pid_t sys_fork(void) -{ - pid_t forkret = fork(); - - if (forkret == (pid_t)0) { - /* Child - reset mypid so sys_getpid does a system call. */ - mypid = (pid_t) -1; - } - - return forkret; -} - -/************************************************************************** - Wrapper for getpid. Ensures we only do a system call *once*. -****************************************************************************/ - -_PUBLIC_ pid_t sys_getpid(void) -{ - if (mypid == (pid_t)-1) - mypid = getpid(); - - return mypid; -} - - _PUBLIC_ int sys_getnameinfo(const struct sockaddr *psa, int salen, char *host, |