From dima@tejblum.dnttm.rssi.ru  Sat Apr  5 04:58:46 1997
Received: from helios.dnttm.ru (uutejb@dnttm.wave.ras.ru [194.85.104.197])
          by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id EAA06217
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 5 Apr 1997 04:58:43 -0800 (PST)
Received: (from uutejb@localhost)
	by helios.dnttm.ru (8.8.5/8.8.5/IP-2) with UUCP id RAA04401
	for FreeBSD-gnats-submit@freebsd.org; Sat, 5 Apr 1997 17:01:26 +0400
Received: (from dima@localhost)
	by tejblum.dnttm.rssi.ru (8.8.5/8.8.5) id RAA01324;
	Sat, 5 Apr 1997 17:00:16 +0400 (MSD)
Message-Id: <199704051300.RAA01324@tejblum.dnttm.rssi.ru>
Date: Sat, 5 Apr 1997 17:00:16 +0400 (MSD)
From: Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
Reply-To: dima@tejblum.dnttm.rssi.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: shutdown(8) don't work if started from an X Window Manager menu
X-Send-Pr-Version: 3.2

>Number:         3202
>Category:       bin
>Synopsis:       shutdown(8) don't work if started from an X Window Manager menu
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr  5 05:00:02 PST 1997
>Closed-Date:    Sat Aug 23 16:18:09 MEST 1997
>Last-Modified:  Sat Aug 23 16:18:32 MEST 1997
>Originator:     Dmitrij Tejblum
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

I tried to start 'shutdown -h now' from my X Window Manager menu.

>Description:

reboot(8) thinks that it started from an interactive shell, and ignore
only SIGHUP.

It seems that somebody, (xdm ?), when die, kills reboot(8) with some other
signal. 

>How-To-Repeat:


>Fix:
	
May be this is not the best way, but it is simple.

*** src/sbin/reboot/reboot.c.orig	Sat Apr  5 16:23:20 1997
--- src/sbin/reboot/reboot.c	Sat Apr  5 16:36:56 1997
***************
*** 130,137 ****
  	if (kill(1, SIGTSTP) == -1)
  		err("SIGTSTP init: %s", strerror(errno));
  
! 	/* Ignore the SIGHUP we get when our parent shell dies. */
! 	(void)signal(SIGHUP, SIG_IGN);
  
  	/* Send a SIGTERM first, a chance to save the buffers. */
  	if (kill(-1, SIGTERM) == -1)
--- 130,137 ----
  	if (kill(1, SIGTSTP) == -1)
  		err("SIGTSTP init: %s", strerror(errno));
  
! 	/* Avoid receiving signals from parent shell or other group leader */
! 	daemon(0,1);
  
  	/* Send a SIGTERM first, a chance to save the buffers. */
  	if (kill(-1, SIGTERM) == -1)

>Release-Note:
>Audit-Trail:

From: j@uriah.heep.sax.de (J Wunsch)
To: dima@tejblum.dnttm.rssi.ru
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/3202: shutdown(8) don't work if started from an X Window Manager menu
Date: Sat, 5 Apr 1997 16:42:23 +0200

 As Dmitrij Tejblum wrote:
 
 > >Fix:
 > 	
 > May be this is not the best way, but it is simple.
 
 I don't think it's a good fix.  If at all, shutdown itself should
 prevent the signal delivery to reboot(8).  After all, shutdown is the
 program that goes into background, while reboot is a plain foreground
 program (which i expect to be able to abort using ^C if i hit it
 quickly after typing the command).
 
 Note that you should also get away with something like
 
 	...	exec "trap 1 2 15 ''; shutdown -h now"
 
 in your window manager menu.
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)

From: Dmitrij Tejblum <dima@tejblum.dnttm.rssi.ru>
To: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/3202: shutdown(8) don't work if started from an X Window Manager menu
Date: Sun, 6 Apr 1997 14:27:34 +0400 (MSD)

 On Sat, 5 Apr 1997, J Wunsch wrote:
 
 > I don't think it's a good fix.  If at all, shutdown itself should
 > prevent the signal delivery to reboot(8).  After all, shutdown is the
 > program that goes into background, while reboot is a plain foreground
 > program (which i expect to be able to abort using ^C if i hit it
 > quickly after typing the command).
 
 Well, second variant:
 
 *** src/sbin/shutdown/shutdown.c.orig	Sat Mar 29 21:48:33 1997
 --- src/sbin/shutdown/shutdown.c	Sun Apr  6 13:58:18 1997
 ***************
 *** 199,204 ****
 --- 199,205 ----
   			(void)printf("shutdown: [pid %d]\n", forkpid);
   			exit(0);
   		}
 + 		setsid();
   	}
   #endif
   	openlog("shutdown", LOG_CONS, LOG_AUTH);
 
 
 > 
 > Note that you should also get away with something like
 > 
 > 	...	exec "trap 1 2 15 ''; shutdown -h now"
 > 
 > in your window manager menu.
 > 
 
 Probably. But such things cannot be called "user-friendly".
 
 	Dima
 
 
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Aug 23 16:18:09 MEST 1997 
State-Changed-Why:  

Suggested fix applied in rev 1.8 of shutdown.c. 
>Unformatted:
