I am trying to run a shell command from a mod_perl2 response handler. It works properly for some number of HTTP requests, but sometimes it fails (somewhat randomly) and I see in my Apache2 error log that one of the Apache2 child processes has died with a segmentation fault. For example, /var/log/apache2/error.log shows:
[Tue Jan 03 12:16:10 2012] [notice] child pid 3538 exit signal Segmentation fault (11) Is this normal? How does one normally run a shell command from a response handler? I do not want to return the command's output to the client. Here is a trivial example response handler that exhibits this behavior: sub handler { my $r = shift || die; my $f = $ENV{DOCUMENT_ROOT} . "/date.txt"; system("date >> $f"); $r->internal_redirect("/date.txt"); return Apache2::Const::OK; } Can anyone provide any guidance? Does this work for you? Note that you may not notice the problem if you don't carefully watch the Apache2 error log (e.g., with "tail -f /var/log/apache2/error.log"), because Apache2 automatically spawns new children processes as needed, and client (such as Firefox or wget, though not curl) seem to automatically re-try the request when it fails, thus giving the illusion of succeeding. P.S. I have posted about this on perlmonks, but thus far have not found a solution: http://www.perlmonks.org/?node_id=945947 -- David Booth, Ph.D. http://dbooth.org/ Opinions expressed herein are those of the author and do not necessarily reflect those of his employer.