Skip to content

Commit

Permalink
Kill all children!
Browse files Browse the repository at this point in the history
  • Loading branch information
mithro committed Jan 17, 2017
1 parent 8a0d381 commit e67abf7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/preview/generate.py
Expand Up @@ -2,6 +2,7 @@
import os
import requests
import shutil
import signal
import subprocess
import sys
import time
Expand Down Expand Up @@ -29,12 +30,15 @@ def generate_thumb(dst, url):
! pngenc snapshot=true \
! filesink location=%s" % (url, dst)
assert not os.path.exists(dst)
p = subprocess.Popen("gst-launch-1.0 "+pipeline, shell=True)
p = subprocess.Popen("gst-launch-1.0 "+pipeline, shell=True, preexec_fn=os.setsid)

start = time.time()
while p.poll() == None and (time.time()-start) < 5.0:
print "Waiting for cmd..."
time.sleep(1)
if p.poll() == None:
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
time.sleep(1)
while p.poll() == None:
p.kill()
time.sleep(1)
Expand Down

0 comments on commit e67abf7

Please sign in to comment.