blob: 843257b70bc6ec46041270b7b6bbc78c8c92706f [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import os
import sys
def main(argv):
if len(argv) < 2:
return 'Usage: {} <main-child-pid>'.format(argv[0])
main_child_pid = int(argv[1])
# wait for child processes
while True:
pid, status = os.wait()
if pid == main_child_pid:
if os.WIFEXITED(status):
return os.WEXITSTATUS(status)
elif os.WIFSIGNALED(status):
os.kill(os.getpid(), os.WTERMSIG(status))
# go to the unreachable place
break
# this should never be reached
return 127
if __name__ == '__main__':
sys.exit(main(sys.argv))