Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: werme@alingo.zk3.dec.com (Eric Werme)
Subject: Re: HELP: My process won't start from /sbin/init.d
Date: 1995/07/07	[thread overview]
Message-ID: <werme.805130754@alingo.zk3.dec.com> (raw)
In-Reply-To: 3tgv3v$q71@fstgds15.tu-graz.ac.at

tom@finwds01.tu-graz.ac.at (Thomas Leitner) writes:

>I wrote a small remote tape daemon which I use to backup our OS/2
>machines over the net to a DAT drive connected to the DEC 3000/600
>running OSF/1 3.2

>A listing of the rtape script is appended to that mail. Now, the problem is,
>that during bootup everything looks fine. The "rtaped daemon started."
>message appears. But when I log-in and check, the rtaped daemon just is
>not running!!!

When the rc3 script finishes, I believe the stray processes all get a signal
that kills them.  (I'm not certain of the genesis and don't have time or
need to learn, so don't ask!)

Our daemons usually call the BSD daemon routine (its in /usr/lib/libutil.a)
This disconnects from controlling session to leave a process running on its
own.

>			/usr/local/bin/rtaped $TAPE &
                                                    ^ Get rid of the ampersand!

Call this early in main():

daemon(nochdir, noclose)
	int nochdir, noclose;
{
	int cpid;

	if ((cpid = fork()) == -1)
		return (-1);
	if (cpid)
		exit(0);
key>>>	(void) setsid();
	if (!nochdir)
		(void) chdir("/");
	if (!noclose) {
		int devnull = open("/dev/null", O_RDWR, 0);

		if (devnull != -1) {
			(void) dup2(devnull, 0);
			(void) dup2(devnull, 1);
			(void) dup2(devnull, 2);
			if (devnull > 2)
				(void) close(devnull);
		}
	}
	return(0);
}

Getting rid of the ampersand ensures that daemon() runs.

Oh yeah - I don't understand this session stuff, etiher.  :-)

-- 
Eric (Ric) Werme         |  werme@zk3.dec.com
Digital Equipment Corp.  |  This space intentionally left blank.



  parent reply	other threads:[~1995-07-07  4:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-07-06  4:00 HELP: My process won't start from /sbin/init.d Thomas Leitner
1995-07-06  4:00 ` Dave Carter
1995-07-07  4:00   ` Thomas Leitner
1995-07-07  4:00 ` Eric Werme [this message]
1995-07-07  4:00   ` Thomas Leitner
1995-07-11  4:00   ` Peter da Silva
1995-07-07  4:00 ` Peter Marksteiner
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox