http://www.perlmonks.org?node_id=1003596

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 (Cardinal) 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 (Chancellor) 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!

    Alexander

    --
    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