15 lines
376 B
Python
Executable File
15 lines
376 B
Python
Executable File
#!/usr/bin/python3
|
|
|
|
import os, sys
|
|
|
|
ret = os.fork()
|
|
if ret == 0:
|
|
print("child process: pid={}, parent process's pid={}".format(os.getpid(), os.getppid()))
|
|
os.execve("/bin/echo", ["echo", "hello from pid={} ".format(os.getpid())], {})
|
|
exit()
|
|
elif ret > 0:
|
|
print("parent process: pid={}, child process's pid={}".format(os.getpid(), ret))
|
|
exit()
|
|
|
|
sys.exit(1)
|