From owner-freebsd-stable Thu May 31 19:12: 0 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 E140B37B43C for ; Thu, 31 May 2001 19:11:55 -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 MAA17437 for ; Fri, 1 Jun 2001 12:11:50 +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 MAA26759; Fri, 1 Jun 2001 12:10:35 +1000 (EST) Message-Id: <200106010210.MAA26759@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: Who's HUPing my daemon? Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 01 Jun 2001 12:10:35 +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 I'm trying to get a daemon running at boot time from rc.d. When the system boots, the script is run, the daemon is started, and all is fine. Then a few seconds later, (possibly at the same time that rc finishes and getty is launched), the daemon gets a SIGHUP and cleans itself up and exits. Running the start script by hand after logging in works and the daemon stays active more or less forever as you expect. Some hackery with ktrace shows that it is a SIGHUP that is killing it, and it is waiting in select() at the time (which is the expected state). The relevent code in main() is like this: if(makedaemon && fork()) exit(0); openlog("bpalogin",LOG_PID,LOG_DAEMON); I'm suspicious that just a plain fork() is not enough to disconnect from the boot sequence but I can't work out what's causing the HUP. Suggestions? (I suspect replacing the code with if (makedaemon) daemon(0,0); will fix it... bloody Linux hackers, no respect for real Unix!) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message