python fork error

Solutions on MaxInterview for python fork error by the best coders in the world

showing results for - "python fork error"
Jaden
22 May 2019
1for i in range(1,4):
2    try:
3         pid = os.fork()
4    except OSError:
5         print ("Error forking process")
6         continue
7    if pid == 0:
8         print "In child process"
9         os._exit(0)
10    print "In parent process"
11
Michaela
17 Sep 2020
1import os
2
3def _fork():
4   raise OSError()
5os.fork = _fork
6
7for i in range(1,4):
8    try:
9         pid = os.fork()
10    except OSError:
11         print ("Error forking process")
12         continue
13    if pid == 0:
14         print "In child process"
15         os._exit(0)
16    print "In parent process"
17