From owner-svn-src-head@FreeBSD.ORG Mon Jun 15 19:24:47 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74FA51065674; Mon, 15 Jun 2009 19:24:47 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 62FA18FC20; Mon, 15 Jun 2009 19:24:47 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5FJOllk099051; Mon, 15 Jun 2009 19:24:47 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5FJOlP3099050; Mon, 15 Jun 2009 19:24:47 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906151924.n5FJOlP3099050@svn.freebsd.org> From: Ed Schouten Date: Mon, 15 Jun 2009 19:24:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194257 - head/sbin/init X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2009 19:24:48 -0000 Author: ed Date: Mon Jun 15 19:24:47 2009 New Revision: 194257 URL: http://svn.freebsd.org/changeset/base/194257 Log: 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. Modified: head/sbin/init/init.c Modified: head/sbin/init/init.c ============================================================================== --- head/sbin/init/init.c Mon Jun 15 19:17:52 2009 (r194256) +++ head/sbin/init/init.c Mon Jun 15 19:24:47 2009 (r194257) @@ -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";