You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
397 B
Python

# Файлы в родительском и дочернем процессе
# $ cat data.txt
# example string1
# example string2
import os
f = open("data.txt")
foo = f.readline()
if os.fork() == 0:
# дочерний процесс
foo = f.readline()
print(f"child: {foo}")
else:
# родительский процесс
foo = f.readline()
print(f"parent: {foo}")