Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to make a thread to wait till a command on shell get completed.

by BrowserUk (Patriarch)
on Dec 02, 2013 at 07:02 UTC ( #1065233=note: print w/replies, xml ) Need Help??


in reply to How to make a thread to wait till a command on shell get completed.

If you run a command (shell or otherwise) using system, the program will block until system returns.

If the program calling system is a single threaded program, that single thread will block.

If the program is a multi-threaded program, whichever thread calls system will block.

Now what is your problem?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.
  • Comment on Re: How to make a thread to wait till a command on shell get completed.

Replies are listed 'Best First'.
Re^2: How to make a thread to wait till a command on shell get completed.
by techman2006 (Beadle) on Dec 02, 2013 at 07:44 UTC

    Basically I am using back tick operator due to which multiple instance of gzip get triggered as the thread is not waiting for the shell to return.

    So how I can achieve blocking of thread in case of back tick.

      Back ticks also wait for the command to finish. Do you use &? Show some code!
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Basically I am using back tick operator due to which multiple instance of gzip get triggered as the thread is not waiting for the shell to return.

      Backticks also block. (Unless you are deliberately backgrounding the command, in which case, don't do that!)

      Post your failing code and you'll get help.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.

      Can you share example code that recreates the issue that you're seeing? Also, do you have a need for using back ticks?

      In the mean time, without seeing your code, I can think of two suggestions. First, use the system command instead of backticks like BrowserUk suggested. Second, try using modules like Archive::Tar to extract your tar files instead of using backticks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1065233]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2023-11-28 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?