I'm designing a script with threads. Basically it call's some shell commands that are active all the time when running them e.g. a tail command will continue until ctrl-c is issued. I got 3 of these commands that are running through a thread because I wanted to be able to continue my script code when such a command was issued and since the script would halt at the first command it came accross, I had to use threads.

The problem is that the last thread seems to override the first threads and shows its output in the terminal but any following code that comes after the thread cannot be outputted. E.g. a simple print "foobar" won't show up in the terminal because it seems occupied by the last (never ending) command issued in the script. Is there a work around so I can output stuff in the terminal because I would want to attach a time to the script so after an x amount of time I want to sent a ctrl-c to the screen to stop the threads. Any other way of timing a thread would be usefull also!

I already tried redirecting the output of the commands to /dev/null but then the shell just remains empty and everything seems to be redirected.