in reply to Re^2: Synchronizing Multiple System Processes
in thread Synchronizing Multiple System Processes

by default should wait until script1.pl finish?.

Yup. In fact, the only exception is in Windows when using the special system(1, ...); syntax.

Of course, if script1.pl launches a child and exits, the main script won't wait for the grandchild to complete. By the way, that means system("command &"); will cause system to return "immediately". (The child, sh, launches command and exits without waiting for command to exit.) Just remove that & if you have it.

Then what do you think is the cause of my symptom above?

Based on the limited information at hand, all I can say with reasonable certainity is that output.txt does not exist.

Replies are listed 'Best First'.
Re^4: Synchronizing Multiple System Processes
by neversaint (Deacon) on Apr 13, 2007 at 05:52 UTC
    Just remove that & if you have it.
    No. I don't have &.
    all I can say with reasonable certainity is that output.txt does not exist.
    Yes it is true. But it is because script1.pl hasn't yet finished in creating output.txt

    ---
    neversaint and everlastingly indebted.......
      If script1.pl returned without having finished creating output.txt, then it didn't create that file.

      What happens if you explicitly close the filehandle for output.txt in script1.pl?

      close OUT or die "Can't close filehandle OUT properly: $!\n";

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}