diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-04 23:04:17 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-04 23:04:17 +0200 |
commit | b182e9ad6011909fdb76358431d23d195febaf54 (patch) | |
tree | 650b66e06387f8b0f7fe054a53150809aede7701 /console-tools | |
parent | 692eeb81a4c54d7d8bf0d2e370c12762b2a16ff7 (diff) | |
download | busybox-w32-b182e9ad6011909fdb76358431d23d195febaf54.tar.gz busybox-w32-b182e9ad6011909fdb76358431d23d195febaf54.tar.bz2 busybox-w32-b182e9ad6011909fdb76358431d23d195febaf54.zip |
libbb: use _exit, not exit, in bb_daemonize_or_rexec()
By the time we reach exit in parent, child already exited or execed.
We should not re-run libc cleanup code.
While at it, introduce bb_daemon_helper() and add a few comments.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'console-tools')
-rw-r--r-- | console-tools/openvt.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/console-tools/openvt.c b/console-tools/openvt.c index f3db28367..423122fe9 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c | |||
@@ -99,7 +99,7 @@ static int find_free_vtno(void) | |||
99 | /*xfunc_error_retval = 3; - do we need compat? */ | 99 | /*xfunc_error_retval = 3; - do we need compat? */ |
100 | if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0) | 100 | if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0) |
101 | bb_perror_msg_and_die("can't find open VT"); | 101 | bb_perror_msg_and_die("can't find open VT"); |
102 | // Not really needed, grep for DAEMON_ONLY_SANITIZE | 102 | // Not really needed, grep for DAEMON_CLOSE_EXTRA_FDS |
103 | // if (fd > 2) | 103 | // if (fd > 2) |
104 | // close(fd); | 104 | // close(fd); |
105 | return vtno; | 105 | return vtno; |
@@ -155,7 +155,7 @@ int openvt_main(int argc UNUSED_PARAM, char **argv) | |||
155 | /* Grab new VT */ | 155 | /* Grab new VT */ |
156 | sprintf(vtname, VC_FORMAT, vtno); | 156 | sprintf(vtname, VC_FORMAT, vtno); |
157 | /* (Try to) clean up stray open fds above fd 2 */ | 157 | /* (Try to) clean up stray open fds above fd 2 */ |
158 | bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL); | 158 | bb_daemon_helper(DAEMON_CLOSE_EXTRA_FDS); |
159 | close(STDIN_FILENO); | 159 | close(STDIN_FILENO); |
160 | /*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */ | 160 | /*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */ |
161 | xopen(vtname, O_RDWR); | 161 | xopen(vtname, O_RDWR); |