do_folk.py 335 B

123456789101112
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import os
  4. print('Process (%s) start...' % os.getpid())
  5. # Only works on Unix/Linux/Mac:
  6. pid = os.fork()
  7. if pid == 0:
  8. print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))
  9. else:
  10. print('I (%s) just created a child process (%s).' % (os.getpid(), pid))