From owner-freebsd-questions Tue Jan 16 10:30:21 2001 Delivered-To: freebsd-questions@freebsd.org Received: from kraeusen.nbrewer.com (unknown [208.42.68.65]) by hub.freebsd.org (Postfix) with ESMTP id D6E3F37B404 for ; Tue, 16 Jan 2001 10:30:02 -0800 (PST) Received: by kraeusen.nbrewer.com (Postfix, from userid 1001) id 94A311743E; Tue, 16 Jan 2001 12:30:01 -0600 (CST) Date: Tue, 16 Jan 2001 12:30:01 -0600 From: Christopher Farley To: cjclark@alum.mit.edu Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Detatch process from terminal? Message-ID: <20010116123001.B34019@northernbrewer.com> Mail-Followup-To: Christopher Farley , cjclark@alum.mit.edu, freebsd-questions@FreeBSD.ORG References: <20010116005127.A31629@northernbrewer.com> <20010115234820.M97980@rfx-64-6-211-149.users.reflexco> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010115234820.M97980@rfx-64-6-211-149.users.reflexco>; from cjclark@reflexnet.net on Mon, Jan 15, 2001 at 11:48:20PM -0800 Organization: Northern Brewer, St. Paul, MN Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Crist J. Clark (cjclark@reflexnet.net) wrote: > On Tue, Jan 16, 2001 at 12:51:27AM -0600, Christopher Farley wrote: > > Is there a shell command that will cause init to fork the new process > > instead of the shell? > > $ cat daemon.sh > #!/bin/sh > > sleep 600 & > > kill $$ > > $ sh daemon.sh > Terminated > $ ps axj | egrep '(^USER|sleep)' > USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND > cjc 51858 1 51857 c04580 0 S p3 0:00.00 sleep 600 I've been testing this from an xterm and found some interesting behavior. If I do this: # xeyes & [1] 34269 # exit The xterm exits and xeyes acquires PPID 1. If I close the xterm by clicking the X in the upper right corner, the xterm and all its children (including xeyes) die. I did not realize until just now that there is a huge difference between these two 'exit strategies'. When Xterm is closed, each of its children receive a SIGHUP. If you exit the shell with the "exit" command, the shell's children to not receive any signals, and then have PPID 1. This confused me. So perhaps I need to get out of the habit of closing xterms with the mouse! -- Christopher Farley Northern Brewer / 1150 Grand Avenue / St. Paul, MN 55105 www.northernbrewer.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message