1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| import os
import sys
import time
import client
os.mkfifo("/tmp/moyendecom", 0600)
os.mkfifo("/tmp/moyendecom2",0600)
pid = os.fork()
if pid == 0:
fif1 = os.open("/tmp/moyendecom", os.O_WRONLY)
fif4 = os.open("/tmp/moyendecom2", os.O_RDONLY)
client.client(fif4, fif1)
print "fils"
sys.exit(0)
else:
fif2 = os.open("/tmp/moyendecom", os.O_RDONLY)
fif3 = os.open("/tmp/moyendecom2", os.O_WRONLY)
f_name = os.read(fif2, 1000)
print "Fils dit: %s" % f_name
f = os.open(f_name, os.O_RDONLY)
buff = os.read(f, 1000)
while (len(buff) > 0):
os.write(fif3, buff)
buff = os.read(f, 1000)
os.unlink("/tmp/moyendecom")
os.unlink("/tmp/moyendecom2")
sys.exit(0) |
Partager