diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-02-22 00:32:17 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-02-22 00:32:17 +0000 |
commit | f11b55c15eb66ff9c01d74cc5a0ed1643d5a363f (patch) | |
tree | e0c2f4801ca52076190428a3c2bb8fe02184a89d | |
parent | d72c8ba8818ccba20efea7e933fda46c6f2537c1 (diff) |
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) |