I try to execute two commands in parallel for 10 seconds using the following code snippet, but the whole process takes more than 10 seconds, as you can see in the output. Could you help me better understand the reason and the best solution for this issue.
stime = datetime.datetime.now() print stime commands = ("sudo /usr/local/bin/snort -v -u snort -g snort -c /usr/local/snort/etc/snort.conf -i eth0 &", "sudo gedit test") for p in commands: p = subprocess.Popen(shlex.split(p), stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT) class Alarm(Exception): pass def alarm_handler(signum, frame): raise Alarm signal.signal(signal.SIGALRM, alarm_handler) signal.alarm(10)
And the conclusion:
2013-01-08 03:30:00.836412 Ooops, taking too long!!!! 2013-01-08 03:30:16.548519
source share