Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2001 12:30:01 -0600
From:      Christopher Farley <chris@northernbrewer.com>
To:        cjclark@alum.mit.edu
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Detatch process from terminal?
Message-ID:  <20010116123001.B34019@northernbrewer.com>
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
References:  <20010116005127.A31629@northernbrewer.com> <20010115234820.M97980@rfx-64-6-211-149.users.reflexco>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010116123001.B34019>