warp-vpn

point to point VPN implementation
git clone git://git.2f30.org/warp-vpn
Log | Files | Refs | README

commit 4a6652547f545a50cac664a6149b30052af73d97
parent 7a56e13096bdfadf4eb8df66d7de327b9056281d
Author: sin <sin@2f30.org>
Date:   Wed, 30 Mar 2016 13:25:19 +0100

use daemon(3) instead of rolling our own

Diffstat:
Mstun.c | 31+------------------------------
1 file changed, 1 insertion(+), 30 deletions(-)

diff --git a/stun.c b/stun.c @@ -746,35 +746,6 @@ err: return ret; } -int -daemonize(void) -{ - int fd; - - if (foreground) - return 0; - switch (fork()) { - case -1: - return -1; - case 0: - break; - default: - _exit(0); - } - if (setsid() < 0) - return -1; - chdir("/"); - fd = open("/dev/null", O_RDWR); - if (fd != -1) { - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - if (fd > 2) - close(fd); - } - return 0; -} - void usage(void) { @@ -822,7 +793,7 @@ main(int argc, char *argv[]) usage(); signal(SIGPIPE, SIG_IGN); - daemonize(); + daemon(0, 0); openlog("stun", LOG_PID | LOG_NDELAY, LOG_DAEMON); devfd = opendev(argv[0]);