You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tosh Cooey <to...@1200group.com> on 2010/02/03 02:05:55 UTC

Best way to pass arguments to an Apache2::SubProcess?

So my will has crumbled, mostly because I'm probably not very good at 
the "resident in memory" part of mod_perl and I will be using 
Apache2::SubProcess to fire off a sub-process.

There seems to be two easy ways to send data to my detached sub-process; 
via an \@args or via $r->subprocess_env->set.

I would like to pass large data structures which I will JSON encode and 
I'm wondering which of the above would be best for that, if any, and 
what the limitations are of either.

Also, I was wondering, in the docs for Apache2::SubProcess in the 
section about properly detaching the sub-process it has in the example:

$r->spawn_proc_prog ('/path/to/detach_script.pl', $args);

Is there a reason $args is used rather than \@args as outlined earlier 
in the docs?

opt arg2: \@argv ( ARRAY ref )

Or is it possible to create an $args->[0..10] and pass that?

Thanks!

Tosh
-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/

Re: Best way to pass arguments to an Apache2::SubProcess?

Posted by Tosh Cooey <to...@1200group.com>.
Probably a stupid question but can't hurt to ask.  In the docs they 
consistently use @argv = qw(foo bar);  Is there a reason for this, can 
the args only be strings as semi-implied by somebody mentioning they 
used JSON in another thread?

Or can I send $argv[0] = LARGE HASH ?

Thanks!

Tosh


Ihnen, David wrote:
> Environment variables have size limits - you should pass it as the args reference because of that, and the fact that you're sending a pointer rather than the whole data helps too, though the system is probably copying it somewhere in there you shouldn't have to worry about it.
> 
> The point they're inferring in the examples is that the second element is a list reference - not whether it's a referenced to a named list or not is irrelevant.
> 
> David
> 
> -----Original Message-----
> From: Tosh Cooey [mailto:tosh@1200group.com] 
> Sent: Tuesday, February 02, 2010 5:06 PM
> To: modperl@perl.apache.org
> Subject: Best way to pass arguments to an Apache2::SubProcess?
> 
> So my will has crumbled, mostly because I'm probably not very good at 
> the "resident in memory" part of mod_perl and I will be using 
> Apache2::SubProcess to fire off a sub-process.
> 
> There seems to be two easy ways to send data to my detached sub-process; 
> via an \@args or via $r->subprocess_env->set.
> 
> I would like to pass large data structures which I will JSON encode and 
> I'm wondering which of the above would be best for that, if any, and 
> what the limitations are of either.
> 
> Also, I was wondering, in the docs for Apache2::SubProcess in the 
> section about properly detaching the sub-process it has in the example:
> 
> $r->spawn_proc_prog ('/path/to/detach_script.pl', $args);
> 
> Is there a reason $args is used rather than \@args as outlined earlier 
> in the docs?
> 
> opt arg2: \@argv ( ARRAY ref )
> 
> Or is it possible to create an $args->[0..10] and pass that?
> 
> Thanks!
> 
> Tosh

-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/

RE: Best way to pass arguments to an Apache2::SubProcess?

Posted by "Ihnen, David" <di...@amazon.com>.
Environment variables have size limits - you should pass it as the args reference because of that, and the fact that you're sending a pointer rather than the whole data helps too, though the system is probably copying it somewhere in there you shouldn't have to worry about it.

The point they're inferring in the examples is that the second element is a list reference - not whether it's a referenced to a named list or not is irrelevant.

David

-----Original Message-----
From: Tosh Cooey [mailto:tosh@1200group.com] 
Sent: Tuesday, February 02, 2010 5:06 PM
To: modperl@perl.apache.org
Subject: Best way to pass arguments to an Apache2::SubProcess?

So my will has crumbled, mostly because I'm probably not very good at 
the "resident in memory" part of mod_perl and I will be using 
Apache2::SubProcess to fire off a sub-process.

There seems to be two easy ways to send data to my detached sub-process; 
via an \@args or via $r->subprocess_env->set.

I would like to pass large data structures which I will JSON encode and 
I'm wondering which of the above would be best for that, if any, and 
what the limitations are of either.

Also, I was wondering, in the docs for Apache2::SubProcess in the 
section about properly detaching the sub-process it has in the example:

$r->spawn_proc_prog ('/path/to/detach_script.pl', $args);

Is there a reason $args is used rather than \@args as outlined earlier 
in the docs?

opt arg2: \@argv ( ARRAY ref )

Or is it possible to create an $args->[0..10] and pass that?

Thanks!

Tosh
-- 
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/