for line in process.communicate():
    if line:
        print('process:', line, end=' ')
if __name__ == '__main__':
    executeCommand('./ascript.sh', runCommand)
time.sleep(1)
os.killpg(process.pid, signal.SIGKILL)
How do I close the stdout-pipe when killing a process started with python subprocess Popen?