I'm trying to use signal.alarm to stop a run-away os.system command. Can anyone exlain the following behavior?
Given following the trivial program: import os import signal def timeoutHandler(signum, frame): print "Timeout" raise ValueError signal.signal(signal.SIGALRM, timeoutHandler) signal.alarm(5) os.system("yes") signal.alarm(0) What I expect is that the Linux/UNIX 'yes' command (which runs until terminated) would be stopped after 5 seconds, when the timeoutHandler is called, thus raising a ValueError and terminating this example program. Instead, the 'yes' command run until it is terminated (by, say, a kill command), at which time the timeoutHandler is called. In other words, the running of the 'yes' command acts like it is blocking the SIGALRM signal until it terminates, at which time the SIGALRM signal is raised. This is quite surprising, and totally defeats my ability to catch a run-away process. Can anyone see what I'm doing wrong? -- http://mail.python.org/mailman/listinfo/python-list