summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-15 19:24:47 +0000
committered <ed@FreeBSD.org>2009-06-15 19:24:47 +0000
commitb3631c54b6e94536e6a880446d8ca851711e70d3 (patch)
tree9580d06587c9b3cfadd42c74a02ae61ed82341bc
parent7de50e3afbbea1bd7bb7ea5fe5f087167ff7980e (diff)
downloadFreeBSD-src-b3631c54b6e94536e6a880446d8ca851711e70d3.zip
FreeBSD-src-b3631c54b6e94536e6a880446d8ca851711e70d3.tar.gz
Remove redundant code from runshutdown() now tcsetsid(3) works reliably.
We can now just call setctty() without any problems. This means the shell running the shutdown script is now the session leader, just like on startup.
-rw-r--r--sbin/init/init.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index baf29bb..8629b90 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1563,30 +1563,13 @@ runshutdown(void)
shell = get_shell();
if ((pid = fork()) == 0) {
- int fd;
-
- /* Assume that init already grab console as ctty before */
-
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
sigaction(SIGTSTP, &sa, (struct sigaction *)0);
sigaction(SIGHUP, &sa, (struct sigaction *)0);
- revoke(_PATH_CONSOLE);
- if ((fd = open(_PATH_CONSOLE, O_RDWR)) == -1)
- warning("can't open %s: %m", _PATH_CONSOLE);
- else {
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- if (fd > 2)
- close(fd);
- }
-
- /*
- * Run the shutdown script.
- */
+ setctty(_PATH_CONSOLE);
char _sh[] = "sh";
char _reboot[] = "reboot";
OpenPOWER on IntegriCloud