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­
    forms."


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

    Chad
    grocery_stocker, Jan 21, 2007
    #1
    1. Advertising

  2. >>>>> "grocery" == grocery stocker <> writes:

    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 - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

    --
    Posted via a free Usenet account from http://www.teranews.com
    Randal L. Schwartz, Jan 21, 2007
    #2
    1. Advertising

  3. grocery_stocker

    Guest

    "grocery_stocker" <> wrote:
    > Taken from Open3
    > " Note if you specify "-" as the command, in an analogous
    > fashion to "open(FOO, "-=E2=94=82")" the child process will just
    > be the forked Perl process rather than an external com=C2=AD
    > mand. This feature isn't yet supported on Win32 plat=C2=AD
    > forms."
    >
    > Okay, what is the big deal if the this is a forked process vs an
    > external command?


    Well, they do very different things.

    > I really can't think
    > of situtation and/or program off the top of my head where this would
    > matter.


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

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Jan 22, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RL
    Replies:
    2
    Views:
    586
  2. jakk
    Replies:
    4
    Views:
    12,034
  3. Replies:
    2
    Views:
    415
    Chris Croughton
    Apr 13, 2005
  4. John Lin
    Replies:
    19
    Views:
    555
    Donn Cave
    Sep 25, 2003
  5. James Colannino

    Detecting problems in a forked process

    James Colannino, Dec 29, 2005, in forum: Python
    Replies:
    2
    Views:
    302
    Donn Cave
    Dec 30, 2005
Loading...

Share This Page