in reply to Starting a process in the background that lives after perl dies.
The above program should show a proud grandparent bragging about what its grandkid is doing. The grandchild then sticks around after the grandparent is dead. Use a loop in the grandchild if you need to prove it to yourself. The grandparent can also do whatever you want it to do, too.#!/usr/bin/perl -w use strict; use POSIX qw{setsid}; ### or just 'use POSIX;' if you plan to use other ### functions from it, of course if ( fork ) { { ### grandparent code goes here print "My grandkid should do a cute l'il ls...\n"; } exit; ### die if we're the parent } if ( fork ) { exit; ### die if we're the parent of this one, too. } ### grandchild code starts here POSIX::setsid; ### should be part of a new session now exec '/bin/ls', '.';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Starting a process in the background that lives after perl dies.
by edebill (Scribe) on Nov 09, 2001 at 04:19 UTC |