Home > Archive > PERL Beginners > December 2005 > running child processes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
running child processes
|
|
| Octavian Rasnita 2005-12-15, 6:57 pm |
| Hi,
Is it possible to create more child processes and let them run, but close
the main program immediately?
I have read (in perldoc perlfork) that:
A way to mark a pseudo-processes as running detached from their parent
(so that the parent would not have to wait() for them if it doesn't want
to) will be provided in future.
Thank you.
Teddy
| |
| Wiggins d'Anconia 2005-12-15, 6:57 pm |
| Octavian Rasnita wrote:
> Hi,
>
> Is it possible to create more child processes and let them run, but close
> the main program immediately?
>
> I have read (in perldoc perlfork) that:
>
> A way to mark a pseudo-processes as running detached from their parent
> (so that the parent would not have to wait() for them if it doesn't want
> to) will be provided in future.
>
> Thank you.
>
> Teddy
>
>
I think the note above is for the special case when the parent still has
work to do but doesn't want to have to wait on the children, which is
subtly different than what you actually asked, aka can the parent close.
Assuming you really do want to close the parent then you should be able
to, though you may want to take a look at the source of,
Proc::Daemon::Init()
Before coding this yourself, it is a handy tool.
HTH,
http://danconia.org
| |
| Octavian Rasnita 2005-12-15, 6:57 pm |
| From: "Wiggins d'Anconia" <wiggins@danconia.org>
> I think the note above is for the special case when the parent still has
> work to do but doesn't want to have to wait on the children, which is
> subtly different than what you actually asked, aka can the parent close.
> Assuming you really do want to close the parent then you should be able
> to, though you may want to take a look at the source of,
>
> Proc::Daemon::Init()
>
> Before coding this yourself, it is a handy tool.
>
Thank you. I will try it or at least I will try to see how it works, because
I have tested it under Windows, and I couldn't install it due to the
following error:
t\01filecreate....POSIX::setsid not implemented on this architecture
I hope I will be able to create a portable program for Unix and Windows.
Teddy
| |
| Jeff Pang 2005-12-15, 9:55 pm |
| yes,you can. the Network Programming with Perl have introduced a way to do that,maybe you can get re. :
sub daemon
{
my $child = fork();
die "can't fork:$!" unless defined $child;
exit 0 if $child;
setsid(); #comming from use POSIX;
open (STDIN, "</dev/null");
open (STDOUT, ">/dev/null");
open (STDERR,">&STDOUT");
chdir $rundir;
umask(0);
$ENV{PATH}='/bin:/usr/bin:/sbin:/usr/sbin';
return $$;
}
-----Original Message-----
From: Octavian Rasnita <orasnita@fcc.ro>
Sent: Dec 16, 2005 5:33 AM
To: beginners@perl.org
Subject: running child processes
Hi,
Is it possible to create more child processes and let them run, but close
the main program immediately?
I have read (in perldoc perlfork) that:
A way to mark a pseudo-processes as running detached from their parent
(so that the parent would not have to wait() for them if it doesn't want
to) will be provided in future.
Thank you.
Teddy
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
|
|
|
|
|