Skip to content

Instantly share code, notes, and snippets.

@hnw
Last active May 15, 2022 12:23
Show Gist options
  • Save hnw/75fa5783758d80139bd7bf7312ddc112 to your computer and use it in GitHub Desktop.
Save hnw/75fa5783758d80139bd7bf7312ddc112 to your computer and use it in GitHub Desktop.
import time
import subprocess
def call_popen():
subprocess.Popen(["sleep", "10"]);
def main():
print(1)
call_popen() # 即座に戻ってくる
print(2)
time.sleep(5)
# プロセス終了後も子プロセスは走り続ける、親プロセスはPID1になる
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment