Re: exec and detach a subprocess

[prev] [thread] [next] [Date index for 2005/02/19]

From: Igor Shevchenko
Subject: Re: exec and detach a subprocess
Date: 17:02 on 19 Feb 2005
On Saturday 19 February 2005 18:44, you wrote:
> Igor Shevchenko wrote:
> > On Saturday 19 February 2005 03:06, Stas Bekman wrote:
> >>What about?
> >>$r->spawn_proc_prog
> >>http://perl.apache.org/docs/2.0/api/Apache/SubProcess.html#C_spawn_proc_p
> >>ro g_
> >
> > Thanks for those links, Stas! I had to find them by myself as they are in
> > docs...
> >
> > The following worked for me:
> >
> > A helper subroutine:
> >
> > sub safe_exec {
> >     my $out_fh = $apr->spawn_proc_prog ( '/path/to/exec_helper.pl', \@_
> > ); close $out_fh;
> > }
>
> I've just committed a change which does this for you if you call that
> method in a void context, so the above can be changed into:
>
>    $apr->spawn_proc_prog ( '/path/to/exec_helper.pl', \@_ );

Thanks!

> > And a helper script:
> >
> > #!/usr/bin/perl -w
> > use strict;
> > use warnings;
> > use POSIX;
>
> performance-wise this is silly :)
> See 13.5.2 in http://modperlbook.org/html/ch13_05.html for details.

Oops, thanks for the tip. I knew about the memory/runtime bloat, I was just 
not realizing that bare "use POSIX" would load all vs none with "use 
POSIX()". exec_helper.pl is rarely-used script, but I'll run thru my 
ModPerl::Registry scripts and modules to fix this... again, thanks!

> > POSIX::setsid;
> >
> > close STDIN;
> > open STDOUT, '+>>', '/path/to/apache/error_log';
> > open STDERR, '>&STDOUT';
> >
> > exec ( @ARGV );
>
> why do you need to call exec() here? It doesn't detach if you don't call
> it? I think it should make no difference at all.

I need to run the real script somehow, hence the call to "exec".

        -- 
        Best Regards,
Igor Shevchenko

(message missing)

exec and detach a subprocess
Igor Shevchenko 23:25 on 18 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:06 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 14:29 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 16:44 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 17:02 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 17:06 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 16:51 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 17:18 on 19 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 17:26 on 19 Feb 2005

Re: exec and detach a subprocess
Igor Shevchenko 14:20 on 20 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:16 on 21 Feb 2005

Re: exec and detach a subprocess
Igor 08:28 on 21 Feb 2005

Re: exec and detach a subprocess
Stas Bekman 01:58 on 22 Feb 2005

Generated at 22:43 on 24 Feb 2005 by mariachi v0.52