Link to home
Start Free TrialLog in
Avatar of izloch2
izloch2

asked on

process forking

Hi! I’m writing a web-based application in Perl that will be running on a Linux machine. At a user's request, the program needs to do some calculations that are supposed to be running on the background. I'm wondering if perl allows to fork a process if it is actually running on a webserver (i know it's not a problem if you start a program through prompt). Thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of jhurst
jhurst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> This way you will not have the problem of the first process remaining defunt until the second completes.
This is somewhow wrong. Father never enters <defunc> state. Its the child, if father will not gather it after it's dead.

But even if You meant that it's child who will not be waited become zombie - it's not really problem if it will be gathered eventually.
Avatar of jhurst
jhurst

I agree on the zombies going away eventually, however it is really better not to have them.  And actually the parent does remain until the signal comes from the child.
> And actually the parent does remain until the signal comes from the child.
Disagree. In fact if the father dies before it's children, children get new parent - init process. And init will gather them immediatelly, so no zombies...
just checked the O'Reilly book and also the perldoc -f fork.  In both cases it says:

"If you fork witjout ever waiting for your children..."

Basically, the parent is expected to wait for the child to send its signal.  I suspect that where we may be disagreeing here is which process.  The important facts are:

1) fork is VERY efficient - makes it desirable to use
2) sadly it leaves zombies until both jobs are done


Of course books are saying so.
But on the other hand, I saw many applications, which are spawning children to do the job and exitig. No zombies (Your 2). As I said it before - init becomes the father of any orphanted child. It's perfectly fine to use this feature.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
do the split if ozo does not get a respomse
Strange You are going accept somehow wrong answers - I pointed some issues.
Bad thing happen on the EE if wrong answer gets accepted by Moderator...
ravenpl, what exactly do you think is wrong in the accepted answer, please be specific, no "many application..." type comments.  I may learn something from this, thanks in advance
> This way you will not have the problem of the first process remaining defunt until the second completes.
This is untrue. I assume first is the father, and second is the child. I already pointed that out. Seems not only moderator skipped my comment but You also.
I would just like to add to this that this is the first time in many years of using experts-exchange that I have seen such unpleasantness and quibllig.
Uh oh - I'd like to note that it's not the first time here, that I see wrong answers! Should I be quiet about that?!? So I will not be unpleasant? That's Your idea for Expert-Exchange?
Don't bother to answer - I already have my idea. And don't bother to write here anything else - like I got prejudiced...