1 from __future__
import print_function
7 def kill_subprocess(process
):
11 # Pass -f=none and --output-style=GNU to get only one line of output per input.
12 cmd
= subprocess
.Popen([sys
.argv
[1],
13 '--obj=' + sys
.argv
[2],
15 '--output-style=GNU'], stdout
=subprocess
.PIPE
, stdin
=subprocess
.PIPE
)
16 watchdog
= threading
.Timer(20, kill_subprocess
, args
=[cmd
])
18 cmd
.stdin
.write(b
'0\n')
20 print(cmd
.stdout
.readline())
21 cmd
.stdin
.write(b
'bad\n')
23 print(cmd
.stdout
.readline())