go_winter_work_2025/python/fork.py
Vitaliy Turov 50f600e168
Some checks failed
Deploy to Server (Docker) / deploy (push) Failing after 9s
feature/train_bash (#7)
Reviewed-on: https://git.gocommunity.ru/walleri1/go_winter_work_2025/pulls/7
Co-authored-by: Vitaliy Turov <walleri1@yandex.ru>
Co-committed-by: Vitaliy Turov <walleri1@yandex.ru>
2025-02-15 11:59:59 +03:00

16 lines
382 B
Python
Executable File

#!/usr/bin/python3
import os
import 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)