-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 6/21/14, 9:46 AM, André Warnier wrote:
> Christopher Schultz wrote:
>> The OP. Look up in the configuration: the "executable" is set to 
>> "perl".
> 
> That's just the default, as it comes in the standard Tomcat 
> distribution. See also 
> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html#Configuration
>
>  The OP never actually said what the script was. Which is a reason
> why I raised the question.

Fair enough.

> He could also be using a stand-alone Java application as a cgi-bin 
> script, for all we know.. Wouldn't that be interesting ?  Would the
> JVM which runs Tomcat actually be smart enough to notice this, and
> not load and run another JVM then ?

No, nor should it. If you wanted to launch another JVM for stability's
sake (e.g. your "standalone" Java program was buggy as heck and might
run out of memory, etc.) then you certainly wouldn't want the JVM to
outsmart you and do something other than what you've asked.

As an aside, I've recently done some hacking on Runtime.exec in a
litte utility program I've written in Java to get the benefit of the
JDBC API (it's a CLI interactive SQL script runner). I wanted to
launch $EDITOR and let the user edit a query in the query buffer, but
launching something like vi from Java is evidently not possible: Java
doesn't have access to the console... only stdin, stdout, and stderr.
I tried writing pumped-streams to just fake it, but basically nothing
works. :(

>>> (not saying that it isn't, but nobody said it was either). As
>>> it stands, whatever it is, it is being run (at first) by perl.
>>> But if perl notice another interpreter in the shebang line, it
>>> will happily cede its turn.
>> 
>> Fair enough. I've seen some stupid things in my time, but having
>> Perl hand-off to some other binary just seems wasteful.
> 
> It is.  Tomcat runs the CGI servlet (actually, a Java JVM does
> that); the CGI servlet sets up a complete CGI environment
> (variables and all), then asks the JVM to load and run a perl
> interpreter (and the JVM probably asks the underlying OS to do
> that).  The perl interpreter loads, reads the cgi script, sees the
> shebang line, and exec's a shell to run the script.  Then the shell
> reads and runs the script.  And the same at each invocation. If one
> is looking for a small footprint and/or performance, that's not 
> exactly the way to go.

Any sane OS, though, would preserve the environment of the process
through those various exec() calls without modification. So going from
Java -> native causes a bit of a stir, but after that, it's fairly
well optimized.

> I was basically raising the question, because it seems to me that,
> if the OP actually read the page 
> https://tomcat.apache.org/tomcat-7.0-doc/cgi-howto.html, it
> nevertheless does not seem that he read it very carefully.

That's pretty clear, given the questions being asked. The page is like
500 words long. It's not like the information is /buried/ in there or
anything. If that page suffers from any problem, it's likely to be
that the information density is too /high/.

> So the fact that perl is the default executable may have escaped
> his attention. And since perl will call a shell to run the script
> if this actually is a shell script with a proper shebang line, he
> may never notice all the above. And then wonder why this appears
> so resource-intensive.
> 
>> 
>>> Anyway, it raises the fundamental question of why go though
>>> all the trouble to run a (possibly perl) cgi-bin script within
>>> Tomcat ?
>> 
>> +1
>> 
> 
> (Also @David) :
> 
> Let's face it : Tomcat is not particularly optimised to run
> cgi-bin scripts, be they perl or otherwise.  There are better tools
> to do this, such as an Apache httpd front-end which the OP seems to
> have been using so far.
> 
> In this particular case, I believe it would probably be better to
> keep the configuration maybe a bit more complex, but probably more
> efficient. There are cases where simpler is not necessarily better,
> and I felt that it was worthwhile pointing this out.

+1

mod_perl is the right answer to this problem. This is one of many
cases where fronting Tomcat with a web server is an appropriate thing
to do.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTqDjeAAoJEBzwKT+lPKRYciEP+wRFd1v3ph1MV7WEZrTTvWKz
XUmhf3QBaJbrAYwaFCJxjJT0LNKKYl8nHM6+kjgjbHsjl30h/0ee9/1Rfbg6SfQO
WHO6cDn1Gu05pmSASMQ9uc8hdUUdL+fpJWhCrUsTUztvON+hRvSJzGY7fYEPFc//
C/P7z5fcdP77ToI80vO7GGB/LXMOtFZHLaliT2ISqqwz0kum2E9VS3c+4rXAOBZs
ZpGwzMlc/rIvx8V5hJE5b4/j53BgsskizMQvLWMY1UJGCS0pPxnHtOLvaUlUwf/g
MHWlIeMIAMEJbyy+wYxE5MMjRu/mtzmEnYfjJtx3C0hHkJqWZwQsSq4Te5+2o9tc
HDmstreWwWRFr1eM5KIKJ8iy+fGM9m/rIGQw42xKylD5L/L5vpDR3KnoNrSluWwI
0/clC3UIrUp+2rgG9Kz+bEFtpdh3qYvi8clFpgbje8BWJo7igHBMWLenEwG22xIS
h90XV9c+T+ZB0r8OYYbqmyOUiM858z8NjoFEq94oCih3t+4oUbSCHQRYCNPFiMWU
mecjWfDMcHh5jUrvmi851uRihGbCKzODo/a7SR7+lRhFX4rlHsXu0AdGjHgZDENC
7IyxUdJpWKeEW32PaBMPMfJR9b/b5dXVGteEWiBcS69nYf+E4LogLoo0y+OVzhGg
9EjHvi//Ng/OLeXEQ+tB
=hvyd
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to