in reply to Re: using system and exec in same script using child
in thread using system and exec in same script using child

To add to ikegami's reply, the parent could exit before the child gets a look-in, and that would (probably) send a SIGHUP to the child and kill it. You should consider a wait or waitpid in the parent before it exits (or maybe IGNORE SIGHUP).
  • Comment on Re^2: using system and exec in same script using child

Replies are listed 'Best First'.
Re^3: using system and exec in same script using child
by convenientstore (Pilgrim) on Jan 11, 2010 at 22:33 UTC
    so, can regular perl program have multiple sub working at sametime? Like displaying moving dots while calculating or simulatenaously launching two external program from perl script.. is that not possible? What I thought of child process is wrong as it's running the same program I am running twice.. i need ways(or at least clue) on how to do above things without running full program of it's own.
      can regular perl program have multiple sub working at sametime?

      Sure can:

      use threads; async{ print "I'm doing this over here while he's...", sleep 1 while 1 }; print "doing that over there, while...", sleep 1 while 1; I'm doing this over here while he's... 1.001 doing that over there, while... 1.001 I'm doing this over here while he's... 0.999772 doing that over there, while... 0.999429 I'm doing this over here while he's... 0.999626 doing that over there, while... 0.99956 I'm doing this over here while he's... 0.999724 doing that over there, while... 0.999355 Terminating on signal SIGINT(2)

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        this is what i wanted to do. i have a master script which need to do some processing of data and once it gets the proper information figured out, it need to launch another script which will log onto another machine and pull some data. Problem is that that script needs to run twice and in order to save time, i like to launch that script twice.. Now that i think about this for little bit perhaps i can do something like
        == master script == doprocessing(); system("launchexternalscript"); gatherinfofromthoseinfo(); == externalscript == fork(); system("gotootherserverandgetinfo");
        does this work?

      so, can regular perl program have multiple sub working at sametime?

      Yes, if threads are used.