summaryrefslogtreecommitdiff
path: root/sbin/mount_portal
diff options
context:
space:
mode:
authorkstailey <kstailey@cvs.openbsd.org>1997-06-10 15:35:42 +0000
committerkstailey <kstailey@cvs.openbsd.org>1997-06-10 15:35:42 +0000
commitcfd539ca4285123ea483dd4be5e0b158976a00c3 (patch)
tree6860f2851c7ceec877cacb6320a944dd7753b260 /sbin/mount_portal
parent841cd71fce05644af6cc40912fc1417e534db1a6 (diff)
deal with random pids from fork(2)
Diffstat (limited to 'sbin/mount_portal')
-rw-r--r--sbin/mount_portal/mount_portal.c21
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;