Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@laixintao
Created February 14, 2020 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laixintao/dbb5a2c38d4aeb30e040ab918bc0b239 to your computer and use it in GitHub Desktop.
Save laixintao/dbb5a2c38d4aeb30e040ab918bc0b239 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import os
import sys
from prompt_toolkit import prompt
pid = os.getpid()
print("old: ", pid)
forked_pid = os.fork()
print("forked pid: ", forked_pid)
if forked_pid == pid:
print("Im exiting...")
sys.exit()
pid = os.getpid()
print("my pid: ", pid)
def run_console():
print("You said: %s" % prompt(">>>: "))
run_console()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment