[ale] Force detachment of a process?

Fletch fletch at phydeaux.org
Sun Dec 22 21:21:39 EST 2002



perldoc -q daemon


Found in /usr/lib/perl5/5.6.1/pod/perlfaq8.pod
       How do I fork a daemon process?

               If by daemon process you mean one that's detached
               (disassociated from its tty), then the following
               process is reported to work on most Unixish sys-
               tems.  Non-Unix users should check their
               Your_OS::Process module for other solutions.

               o   Open /dev/tty and use the TIOCNOTTY ioctl on
                   it.  See tty(4) for details.  Or better yet,
                   you can just use the POSIX::setsid() function,
                   so you don't have to worry about process
                   groups.

               o   Change directory to /

               o   Reopen STDIN, STDOUT, and STDERR so they're
                   not connected to the old tty.

               o   Background yourself like this:

                       fork && exit;

               The Proc::Daemon module, available from CPAN, pro-
               vides a function to perform these actions for you.


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 294-0820 (m)      |  scary questions." -- Jules                =(___)=
                      |                                               U
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list