Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Apache forbids fork() and thread()

by MARVion (Novice)
on Nov 13, 2012 at 12:16 UTC ( #1003596=perlquestion: print w/replies, xml ) Need Help??
MARVion has asked for the wisdom of the Perl Monks concerning the following question:

Hi to all of you, I'm a student from Germany. Because this site helped me a lot in the past, I now have to ask a question for which I can't find a good answer through the whole Google. I have web based software running local on a Windows machine on a XAMPP server. The copy of that is running on a linux machine, also Apache server. I NEED to create a complete new free process but when I try forking or threading, perl breaks down and the complete software throws errors. Using a system call worked fine locally but needs a lot of time (it's a spearate *.pl script I am calling). So this is the reason why I need to run it indepentand from within the web based program. Is there any way, any possiblity, workaround or Apache modification resolving my problem? I also tried Proc::Daemon, but this also isn't working because of the simulation of a fork(). I also tried thread->detach but, for sure, it wasn't working at all. The error thrown is a standard 500 server error, with the text:Premature end of script headers. I'm looking forward to hear from you! It would be very nice if somebody could help me with that problem I have for about three days now. Yours sincerely MARV

Replies are listed 'Best First'.
Re: Apache forbids fork() and thread()
by marto (Archbishop) on Nov 13, 2012 at 12:29 UTC

    "The error thrown is a standard 500 server error"

    And what did the web server logging tell you? Regardless of the issues already pointed out, you need to do basic debugging to help locate where your problems are. See the debugging advice here.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Apache forbids fork() and thread()
by afoken (Abbot) on Nov 13, 2012 at 12:21 UTC

    Which system has this problem? Windows or Linux?

    Are you aware that Windows has neither fork() nor exec()? Are you aware that Apache uses different process models on Linux and Windows? This also affects mod_perl!


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Hi, thanks for your quick reply. Both systems have this problem, that nothing is working when trying to fork() or thread. I tried all possible functions like, fork, exec, system with &, Proc::Daemon and other things on both machines. The functions which do not create a process or thread for their own like system() are working fine, but this causes a lot of delay due to the time the called script needs. I'm working with mod_perl, that's correct. Because I thought about the different behavoiurs of Apache I tried all possibilities on both systems. Greetz
Re: Apache forbids fork() and thread()
by Anonymous Monk on Nov 13, 2012 at 12:38 UTC
      Hi, thanks for the links! I tried a lot of things (in the links you posted), Shell says Syntax is ok, there are no fatalsToBrowser errors displayed in the browser, just the header which is printed anyway. I compiled with -cwT, anything ok. When running the code without the fork statement, anything works fine, when running it with the fork statement anything collapsed, also Perl for itself. Windows is telling me Perl isn't working anymore and asks for sending some more information (what I denied). I think it's an environment problem of Apache, but I don't know it for sure as I'm not that familiar with server configurations. Greetz

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-09-24 05:18 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (191 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!