From: Roy Marples Date: Fri, 7 Feb 2014 17:48:13 +0000 (+0000) Subject: writepid is now a static inline function X-Git-Tag: v6.3.0~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ebc8827ae56c4ece5b61049ab9e09d1448aed709;p=thirdparty%2Fdhcpcd.git writepid is now a static inline function --- diff --git a/common.c b/common.c index 27100205..02ea4ae0 100644 --- a/common.c +++ b/common.c @@ -224,17 +224,3 @@ uptime(void) return tv.tv_sec; } -int -writepid(int fd, pid_t pid) -{ - char spid[16]; - ssize_t len; - - if (ftruncate(fd, (off_t)0) == -1) - return -1; - snprintf(spid, sizeof(spid), "%u\n", pid); - len = pwrite(fd, spid, strlen(spid), (off_t)0); - if (len != (ssize_t)strlen(spid)) - return -1; - return 0; -} diff --git a/common.h b/common.h index 2cea3151..cf2d37b2 100644 --- a/common.h +++ b/common.h @@ -107,6 +107,5 @@ int get_monotonic(struct timeval *); ssize_t setvar(char ***, const char *, const char *, const char *); ssize_t setvard(char ***, const char *, const char *, int); time_t uptime(void); -int writepid(int, pid_t); #endif diff --git a/dhcpcd.c b/dhcpcd.c index 669f359f..33d2f835 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -186,6 +186,15 @@ handle_exit_timeout(__unused void *arg) eloop_timeout_add_sec(timeout, handle_exit_timeout, NULL); } +static inline int +writepid(int fd, pid_t pid) +{ + + if (ftruncate(fd, (off_t)0) == -1) + return -1; + return dprintf(fd, "%d\n", pid); +} + /* Returns the pid of the child, otherwise 0. */ pid_t daemonise(void)