diff options
author | 1997-06-10 15:35:41 +0000 | |
---|---|---|
committer | 1997-06-10 15:35:41 +0000 | |
commit | 7ece07eb253293e00e9a3a74c3b8fde36678174d (patch) | |
tree | 64a5a4073b765790defb13b3224b9e6d80e98384 | |
parent | be more explicit about fs_type (diff) | |
download | wireguard-openbsd-7ece07eb253293e00e9a3a74c3b8fde36678174d.tar.xz wireguard-openbsd-7ece07eb253293e00e9a3a74c3b8fde36678174d.zip |
deal with random pids from fork(2)
-rw-r--r-- | sbin/mount_portal/mount_portal.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c index 959f8f563f1..b6d6536d095 100644 --- a/sbin/mount_portal/mount_portal.c +++ b/sbin/mount_portal/mount_portal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mount_portal.c,v 1.7 1997/03/23 03:52:14 millert Exp $ */ +/* $OpenBSD: mount_portal.c,v 1.8 1997/06/10 15:35:41 kstailey Exp $ */ /* $NetBSD: mount_portal.c,v 1.8 1996/04/13 01:31:54 jtc Exp $ */ /* @@ -47,7 +47,7 @@ char copyright[] = #if 0 static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95"; #else -static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.7 1997/03/23 03:52:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.8 1997/06/10 15:35:41 kstailey Exp $"; #endif #endif /* not lint */ @@ -182,23 +182,26 @@ main(argc, argv) (void)listen(so, 5); args.pa_socket = so; - (void)snprintf(tag, sizeof(tag), "portal:%d", getpid() + 1); - args.pa_config = tag; - - rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args); - if (rc < 0) - err(1, "mount(2)"); /* - * Everything is ready to go - now is a good time to fork + * Must fork before mount to get pid in name right. */ daemon(0, 0); + (void)snprintf(tag, sizeof(tag), "portal:%d", getpid()); + args.pa_config = tag; + /* * Start logging (and change name) */ openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON); + rc = mount(MOUNT_PORTAL, mountpt, mntflags, &args); + if (rc < 0) { + syslog(LOG_ERR, "mount: %m"); + exit(1); + } + q.q_forw = q.q_back = &q; readcf = 1; |