From owner-freebsd-stable Sun Jun 3 21: 5:14 2001 Delivered-To: freebsd-stable@freebsd.org Received: from ns.itga.com.au (ns.itga.com.au [202.53.40.210]) by hub.freebsd.org (Postfix) with ESMTP id B34A537B401 for ; Sun, 3 Jun 2001 21:05:10 -0700 (PDT) (envelope-from gnb@itga.com.au) Received: from lightning.itga.com.au (lightning.itga.com.au [192.168.71.20]) by ns.itga.com.au (8.9.3/8.9.3) with ESMTP id OAA40062 for ; Mon, 4 Jun 2001 14:04:58 +1000 (EST) (envelope-from gnb@itga.com.au) Received: from itga.com.au (lightning.itga.com.au [192.168.71.20]) by lightning.itga.com.au (8.9.3/8.9.3) with ESMTP id OAA28199; Mon, 4 Jun 2001 14:03:43 +1000 (EST) Message-Id: <200106040403.OAA28199@lightning.itga.com.au> X-Mailer: exmh version 2.4 05/15/2001 with nmh-1.0.4 From: Gregory Bond To: stable@freebsd.org Subject: Re: Who's HUPing my daemon? In-reply-to: Your message of Fri, 01 Jun 2001 22:20:52 +1000. Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 04 Jun 2001 14:03:42 +1000 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thanks to all, especially Phil Homewood who explained what is happening. Basically, init does the following fork() open /dev/console as STDIN/STDOUT/STDERR setsid() exec /etc/rc and when the rc scrip ends, noone has /dev/console open so it is closed and all processes with this as the controlling terminal get SIGHUP'd. The fix is to use the daemon() call to background and disassociate from the controlling terminal. I have patched the bpalogin client and this fixes the problem, and I have sent a patch to the program maintainer. Other options would include running bpalogin under nohup in the rc.d script (cute, and works for programs without source code!) and using fork()+setsid() rather than daemon() (for better portability to Linux/Solaris etc). To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message