Subject: bin/31531: shutdown(8) quietly exit if execed from login shell
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <taca@back-street.net>
List: netbsd-bugs
Date: 10/09/2005 14:59:00
>Number: 31531
>Category: bin
>Synopsis: shutdown(8) quietly exit if execed from login shell
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 09 14:59:00 +0000 2005
>Originator: Takahiro Kambe
>Release: NetBSD 3.99.9
>Organization:
Takahiro Kambe
>Environment:
System: NetBSD reef.back-street.net 3.99.9 NetBSD 3.99.9 (CF-R3E) #8: Sun Oct 2 12:09:11 JST 2005 taca@reef.back-street.net:/data/i386/obj/sys/arch/i386/compile/CF-R3E i386
Architecture: i386
Machine: i386
>Description:
shutdown(8) quietly exit if it is execed from login shell.
I don't know wheather it is a bug or specification, but my old
memory tells me that there was no such behavior with older *BSD.
>How-To-Repeat:
1. login root or normal user and execute su(1) with exec shell
builtin coommand.
% exec su
Password:
#
2. exec shutdown(8).
# exec /sbin/shutdown now
3. Wait, but nothing happens.
>Fix:
Background shutdown(8) process is killed with SIGHUP by init(8)
as a member of login session process. So, make shutdown(8) have
its own session.
--- shutdown.c.orig 2005-10-09 23:50:29.000000000 +0900
+++ shutdown.c 2005-10-09 23:50:30.000000000 +0900
@@ -214,17 +214,11 @@
#else
(void)setpriority(PRIO_PROCESS, 0, PRIO_MIN);
if (nofork == 0) {
- int forkpid;
-
- forkpid = fork();
- if (forkpid == -1) {
+ if (daemon(0, 1)) {
perror("shutdown: fork");
exit(1);
}
- if (forkpid) {
- (void)printf("shutdown: [pid %d]\n", forkpid);
- exit(0);
- }
+ (void)printf("shutdown: [pid %d]\n", getpid());
}
#endif
openlog("shutdown", LOG_CONS, LOG_AUTH);
>Unformatted: