Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Backticks with Apache hang

by Marcello (Hermit)
on Oct 13, 2005 at 09:45 UTC ( #499833=perlquestion: print w/replies, xml ) Need Help??

Marcello has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have run into a strange problem. I have a simple Perl script which looks at the process table entries using the command:
my @lines = `ps x`;
When run from the command-line, all works fine. But when I access the script using the webbrowser and Apache, the perl script is started but hangs on the backticks statement. The file permissions of the Perl script are ok, and also Apache is using the correct user and group while executing the Perl script.

I also tried using a pipe instead of backticks, but the script also hangs on the pipe open.

What might be the cause of this hang?

Best regards

Replies are listed 'Best First'.
Re: Backticks with Apache hang
by jbrugger (Parson) on Oct 13, 2005 at 10:48 UTC
    Did you look in your apache's error log? are ther error messages? or does it 'just seem to hang'? I don't think there's enough information probided by you.

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: Backticks with Apache hang
by da_kow (Novice) on Oct 13, 2005 at 16:11 UTC

    I had the same problem few weeks ago.

    I've managed to isolate the problem to a weird interraction between Apache::Session via a NFS share and the offending code. Whenever I called the code that used the Session, any execution resulting in a fork (backtick, pipe, watever) would end with a hanged Apache child and a frozen process.

    What was weird is that the problem occured systematically with RedHat EL4, but not on the boxes running RHEL3...

    The problem disapeared when we moved the session management to MySQL.

    Try to strace the processed? When I did, it at least helped be figure the interraction of everything (it was not my code).

    Hope this help, good luck.

      strace revealed the following:
      fork() = -1 EAGAIN (Resource temporar +ily unavailable) rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_0], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [RT_0], NULL, 8) = 0 nanosleep({5, 0}, {5, 0}) = 0
      Which is really strange, what might cause the fork to fail for Apache requests?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://499833]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-06-02 16:04 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (19 votes). Check out past polls.