From f11b55c15eb66ff9c01d74cc5a0ed1643d5a363f Mon Sep 17 00:00:00 2001 From: Michael Shalayeff Date: Fri, 22 Feb 2002 00:32:17 +0000 Subject: mark opened device and socket as close on exec; idea from freebsd pr/35182 --- usr.sbin/apmd/apmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3