diff options
author | 2002-02-22 00:32:16 +0000 | |
---|---|---|
committer | 2002-02-22 00:32:16 +0000 | |
commit | 5b2b631e46acc2ee3aa05d38928da357b70d11d8 (patch) | |
tree | eb13be111061e19c9f2ccee2fad3f6dbb50acf2c | |
parent | if file mode known, try to avoid a race.. i think. millert spotted a bug in my first draft (diff) | |
download | wireguard-openbsd-5b2b631e46acc2ee3aa05d38928da357b70d11d8.tar.xz wireguard-openbsd-5b2b631e46acc2ee3aa05d38928da357b70d11d8.zip |
mark opened device and socket as close on exec; idea from freebsd pr/35182
-rw-r--r-- | usr.sbin/apmd/apmd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 2ed7e14f10f..ffe6518e6b4 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.22 2001/12/12 17:03:39 mickey Exp $ */ +/* $OpenBSD: apmd.c,v 1.23 2002/02/22 00:32:16 mickey Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -391,8 +391,14 @@ main(int argc, char *argv[]) if ((ctl_fd = open(fname, O_RDWR)) == -1) error("cannot open device file `%s'", fname); + if (fcntl(ctl_fd, F_SETFD, 1) == -1) + error("cannot set close-on-exec for `%s'", fname); + sock_fd = bind_socket(sockname); + if (fcntl(sock_fd, F_SETFD, 1) == -1) + error("cannot set close-on-exec for the socket", NULL); + power_status(ctl_fd, 1, 0); if (statonly) |