35 lines
563 B
Ruby
35 lines
563 B
Ruby
|
#!/usr/bin/ruby -w
|
||
|
|
||
|
system("clear")
|
||
|
rd, wr = IO.pipe
|
||
|
|
||
|
print "\nPere : creation processus fils"
|
||
|
|
||
|
if Process.fork
|
||
|
wr.close
|
||
|
print "\nPere : lecture donnee depuis tube rd"
|
||
|
sleep 1
|
||
|
|
||
|
while ! rd.eof
|
||
|
c=rd.readchar
|
||
|
print "\ncaractere recu...."
|
||
|
putc c
|
||
|
print "\nattente...."
|
||
|
sleep 3
|
||
|
end
|
||
|
print "\nfin lecteur*\n"
|
||
|
rd.close
|
||
|
|
||
|
else
|
||
|
rd.close
|
||
|
sleep 1
|
||
|
print "\nFils : envoi donnee vers tube wr"
|
||
|
for i in 'a'..'g'
|
||
|
print "\n------>envoi du caractere ", i
|
||
|
wr.write i
|
||
|
sleep 1
|
||
|
end
|
||
|
print "\nfin redacteur*\n"
|
||
|
wr.close
|
||
|
end
|