On 12/11/07, Alfie John <[EMAIL PROTECTED]> wrote:
> > There are several problems when using 'backtick' here:
> > 1) From my tests, be it a background or foreground command within
> > backticks, your process has to wait for it to finish to continue. A
> > simple Mason file can address this problem:
> >
> > <% rand() %>
> > <%init>
> >  `sleep 20 &`;
> > </%init>
> >
> > and see how long it takes to render your webpage.
> >
> > My point: if the external program takes some non-trivial time to
> > finish, qx// and the likes are not the ways OP might need.
> >
> > 2) "backtick" is usually not used in a void context, this might just
> > be a trivial Perl problem though.
>
> Interesting. I would have thought backticks would have returned
> straight away since the process was backgrounded. system() however
> does what you want:
>
> <%init>
>  print "before: " . time() . "<br />";
>  system "sleep 200 &";
>  print "after" . time() . "<br />";
> </%init>
>
> As you can see from the output, before and after are the same. If you
> 'ps aux | grep sleep', you will see apache is resting.

I guess there is probably some security consideration not to use
"system" that way. see perldoc perlsec..

I did some fast tests on that code from mod_perl webpage and it seems
that the three "open" lines on STDIN, STDOUT, STDERR should become
"close"(not "open"), at least in my current system (Mason+FastCGI)
when I didnot use Apache::SubProcess. other lines are just fine..

Regards,
Xicheng

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to