Whas is the difference between forked process vs external command in this case.

Discussion in 'Perl Misc' started by grocery_stocker, Jan 21, 2007.

  1. Taken from Open3
    " Note if you specify "-" as the command, in an analogous
    fashion to "open(FOO, "-│")" the child process will just
    be the forked Perl process rather than an external com­
    mand. This feature isn't yet supported on Win32 plat­

    Okay, what is the big deal if the this is a forked process vs an
    external command? I really can't think
    of situtation and/or program off the top of my head where this would

    grocery_stocker, Jan 21, 2007
    1. Advertisements

  2. grocery> Okay, what is the big deal if the this is a forked process vs an
    grocery> external command?

    forked process: still running perl code from the same program
    external command: brand new data and code
    Randal L. Schwartz, Jan 21, 2007
    1. Advertisements

  3. grocery_stocker

    xhoster Guest

    Well, they do very different things.
    You can't? Let's say the other program is "ls". If you do the plain fork
    instead of starting the external "ls" command (which is probably
    implemented as the combination of fork followed by an exec) , then the
    other program is not "ls", it is perl. That seems like a big difference to
    me. I rarely confuse perl with ls. On the other hand, let is say the
    other program is perl. If you use the forking method, then the new process
    has a copy (COW) of all the old process's data, and all the old process's
    modules are already loaded (which is often a good thing, and sometimes a
    bad thing, for example if you have objects holding connections to servers
    that clean up on exit, it may clean up when the child exits while the
    parent is still expecting to use them), and the code is already compiled.
    And (I suspect) it is a lot faster to fork than to start up a whole new
    interpreter from scratch by forking and then execing (and compiling...)

    xhoster, Jan 22, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.