This commit is contained in:
Denis Zheleztsov 2016-11-10 12:17:31 +03:00
parent c1bec161be
commit e7f9037976
3 changed files with 0 additions and 45 deletions

10
t/b.sh
View File

@ -1,10 +0,0 @@
#!/bin/bash
set -e
echo $$ > /var/tmp/surok.spid
while true; do
cat txt
sleep 2
done

34
t/f.py
View File

@ -1,34 +0,0 @@
#!/usr/bin/python3
import os
import subprocess
from time import sleep
import sys
def child():
bashCommand = "./b.sh"
process = subprocess.Popen(bashCommand, stdout=sys.stdout)
# output = process.communicate()
return process
def parent():
newpid = os.fork()
if newpid == 0:
child()
else:
pids = (os.getpid(), newpid)
print("parent: %d, child: %d\n" % pids)
c = 0
while c < 5:
sleep(2)
p = open('/var/tmp/surok.spid')
cpid = p.read()
p.close()
print(cpid, c)
c = c + 1
parent()

1
t/txt
View File

@ -1 +0,0 @@
OK