in reply to background w/out fork?

Is your aim to get rid of forking completely, or just to get it out of your code? Because the shell command still forks. That's just the way Unix works.

----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.

Replies are listed 'Best First'.
Re^2: background w/out fork?
by geektron (Curate) on Jun 30, 2004 at 21:34 UTC
    the goal is to detach from the tty ... if the job needs to be invoked via command line, it's still attached.
      Then what you want is
      nohup /usr/local/sbin/relaydelay.pl $CONFIG > /var/log/relaydelay.l +og 2>&1 &
      Update: Fix Typoes. It's been a long month....

      ----
      I Go Back to Sleep, Now.

      OGB

        don't forget stdin! i don't know if it's really needed but i think it keeps my ssh from hanging when i exit (maybe because some process still has the pty open as stdin?)

        nohup /usr/local/sbin/relaydelay.pl $CONFIG >/var/log/relaydelay.lg 2> +&1 </dev/null &
      If you want to detach from the tty, and from session group, then use Proc::Daemon. It handles all the details of the double fork, creating new session group, and closing all filehandles. You will need to reopen stderr or stdout after the process becomes a daemon.