What I need is for a parent process to create a child that is not merely a copy of the parent. I have a parent process that will have a lot of overhead and the child needs to be free of that overhead. Also, I need the parent to wait until the child is done before exiting the script.

The code I have does not wait. My assumption is that getting the parent of 1 means that I am getting a child without the overhead of the parent.

Code is Below

# Fork the process as its own parent. I am assuming by # recieving a parent of 1 that the Child is not just a copy # of the parent. unless (fork) { # Create first child unless (fork) { # Create Second Child sleep 1 until getppid == 1; # Execute our command exec "distill mypsfile.ps"; exit 0; } exit 0; } # Wait for the first child to be reaped # How can we make this wait until the exec statement # has completed before exiting ????????? wait;
edit (broquaint): changed <pre> <code> tags

In reply to Creating Child without overhead of Parent by cxbast

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.