diff options
| author | Natanael Copa <ncopa@alpinelinux.org> | 2023-08-30 13:17:07 +0200 | 
|---|---|---|
| committer | William Hubbs <w.d.hubbs@gmail.com> | 2023-09-12 22:53:12 -0500 | 
| commit | c199c5cf6e39d6e21b92bddba7beeebcc3afca79 (patch) | |
| tree | 2c6f39ffe0f23aace0e70e8766fc731af3ba0f80 /src/supervise-daemon | |
| parent | 5bfb592d75f2e2ccfc94cb510c5eca755767dfbb (diff) | |
| download | openrc-c199c5cf6e39d6e21b92bddba7beeebcc3afca79.tar.xz | |
misc: add cloexec_fds_from() helper function
Move logic to set file descriptors to a cloexec_fds_from() function in
misc.c so it can be shared by both supervisor-daemon and
start-stop-daemon, and hide the details behind.
Diffstat (limited to 'src/supervise-daemon')
| -rw-r--r-- | src/supervise-daemon/supervise-daemon.c | 22 | 
1 files changed, 2 insertions, 20 deletions
diff --git a/src/supervise-daemon/supervise-daemon.c b/src/supervise-daemon/supervise-daemon.c index e36d0314..f0f298d2 100644 --- a/src/supervise-daemon/supervise-daemon.c +++ b/src/supervise-daemon/supervise-daemon.c @@ -22,11 +22,6 @@  #define ONE_SECOND    1000000000  #define ONE_MS           1000000 -#ifdef HAVE_CLOSE_RANGE -/* For close_range() */ -# define _GNU_SOURCE -#endif -  #include <errno.h>  #include <fcntl.h>  #include <getopt.h> @@ -203,18 +198,6 @@ static inline int ioprio_set(int which RC_UNUSED, int who RC_UNUSED,  }  #endif -#ifndef CLOSE_RANGE_CLOEXEC -# define CLOSE_RANGE_CLOEXEC	(1U << 2) -#endif -#ifndef HAVE_CLOSE_RANGE -static inline int close_range(int first RC_UNUSED, -			      int last RC_UNUSED, -			      unsigned int flags RC_UNUSED) -{ -	return -1; -} -#endif -  static void cleanup(void)  {  	free(changeuser); @@ -582,9 +565,8 @@ RC_NORETURN static void child_process(char *exec, char **argv)  	if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))  		dup2(stderr_fd, STDERR_FILENO); -	if (close_range(3, UINT_MAX, CLOSE_RANGE_CLOEXEC) < 0) -		for (i = getdtablesize() - 1; i >= 3; --i) -			fcntl(i, F_SETFD, FD_CLOEXEC); +	cloexec_fds_from(3); +  	cmdline = make_cmdline(argv);  	syslog(LOG_INFO, "Child command line: %s", cmdline);  	free(cmdline);  | 
