in reply to background w/out fork?

It should work when the system boots, but if a user restarts it by hand from their terminal, it will end up as part of their session (and their terminal), and so their shell may kill it when they log out.

Personally, I would run the script under daemontools, but BUU's right that it shouldn't be too hard to wrap your code. You can probably even do it in a seperate file:

#!/usr/bin/perl use POSIX qw(setsid); fork and exit; fork and exit; chdir("/"); setsid; exec @ARGV or die "Couldn't exec @ARGV: $!\n";
(there may be other stuff; see a copy of Stevens)

If you call this script daemon.pl, you'd just put in your init.d script:

/usr/local/sbin/daemon.pl \ /usr/local/sbin/relaydelay.pl $CONFIG \ >/var/log/relaydelay.log 2>&1
Update: As dave_the_m points out, the order of redirections is important, and I've fixed it here.

Replies are listed 'Best First'.
Re^2: background w/out fork?
by geektron (Curate) on Jun 30, 2004 at 21:37 UTC
    i'm being cautiously lazy. the script in question is some funky looking Milter interface ... i don't want to start hacking and wrapping ...
      By running it from init.d and using shell commands, you're already doing some hacking and wrapping. It's just a matter of degree. :)
        point taken.

        it's already fired from init.d .... just not properly detaching when a user runs it ...