SPUG: Creating a NON zombie daemon
David AA Poncelow
panache at wolfenet.com
Tue Apr 18 20:44:29 CDT 2000
It looks like you need to use the exec() function instead of the
system() function. From the camel-head: 'Unlike system, the
executed command is not forked off into a child process. An exec
completely replaces the script in its current process.'
On Mon, Apr 17, 2000 at 06:01:27PM -0700, Thomas Holkenbrink wrote:
> I have a Java application that will run like a daemon for a Perl program...
> but How do I start the daemon up and Only have one PID associated with it?
>
> I have tried like this but I get two process?
> <CODE>
>
> $|=1;
> print "Starting Server\n";
>
> use POSIX 'setsid';
>
> chdir '/' or die "Can't chdir to /: $!";
> open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
> open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
> defined(my $pid = fork) or die "Can't fork: $!";
> exit if $pid;
> setsid or die "Can't start a new session: $!";
> open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
>
> system("java myClass.class");
>
> </CODE>
>
> I would like to be able to something similar in a init script but it wont
> work??? any ideas? It seems to function but nothing ever shows up in a "ps
> -ef"
>
> Thomas
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
> SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
> Email to majordomo at pm.org: "action" spug-list your_address
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
Email to majordomo at pm.org: "action" spug-list your_address
More information about the spug-list
mailing list