in reply to Re: explain my code
in thread explain my fork

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: explain my code
by eric256 (Parson) on Jun 22, 2006 at 19:22 UTC
    use strict; use warnings; print "FIRST\n"; fork(); print "SECOND\n";
    Outputs:
    FIRST SECOND SECOND

    It would therefor appear that it DOES execute that command twice. If you think it does not, please supply what you are using as evidence so that we might see what you are doing differently.


    ___________
    Eric Hodges
      I agree, your example is correct, that's how fork works.

      My demo above is what i'm doing. If I run that from the command line, it executes twice, yes. But if apache executes it, some_cmd is only executed once. I expect it has something to do with my close STDOUT line, which in a normal script apparently is a synonym for exit() (when run by apache). So, really, I don't understand why it ran some_cmd once, when it should have been either none or twice, I could rationally explain either of those outcomes

      It's not what you look like, when you're doin' what you’re doin'.
      It's what you’re doin' when you’re doin' what you look like you’re doin'!
           - Charles Wright & the Watts 103rd Street Rhythm Band, Express yourself
Re^3: explain my code
by Joost (Canon) on Jun 22, 2006 at 19:18 UTC