Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site inuxc.UUCP
Path: utzoo!watmath!clyde!burl!hou3c!hocda!houxm!ihnp4!inuxc!mcferrin
From: mcferrin@inuxc.UUCP (P McFerrin)
Newsgroups: net.unix-wizards,net.lang.c
Subject: Re: USG 5.0 r2: can my program tell if it is in background/nohup'd?
Message-ID: <1015@inuxc.UUCP>
Date: Wed, 15-Aug-84 02:32:21 EDT
Article-I.D.: inuxc.1015
Posted: Wed Aug 15 02:32:21 1984
Date-Received: Thu, 16-Aug-84 00:34:06 EDT
References: <522@burl.UUCP>
Organization: AT&T Consumer Products Div., Indianapolis
Lines: 13

I can give you a couple of hints to determine if you are running in backgroun
with or without hohup.

Usually---- a background process and a nohupped process will have its
stdin to /dev/null which is NOT a tty.  Use isatty(3c) to determine this
(under ttyname(3c).

Another tip is that the hangup signal is ignored for nohupped process.
You can determine this by executing a signal system call in attempting
to set the 'func' to SIG_DFL, signal returnes the previous value of 'func'
which you can check to see if it is SIG_IGN.  I do this sort of thing
on a terminal lock program which I make sure that the hangup signal is NOT
ignored so that I can die whenever the terminal is hung up.