Skip to content

Instantly share code, notes, and snippets.

@ids1024
Created October 12, 2020 02:58
Show Gist options
  • Save ids1024/c200eebe8544909d66bcd18deec7b682 to your computer and use it in GitHub Desktop.
Save ids1024/c200eebe8544909d66bcd18deec7b682 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
import sys
import pty
import subprocess
pid, fd = pty.fork()
if pid == 0:
sys.exit(subprocess.call(sys.argv[1:]))
else:
try:
for l in os.fdopen(fd):
sys.stdout.write(l)
except Exception:
pass
sys.exit(os.WEXITSTATUS(os.waitpid(pid, 0)[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment