apue里說匿名管道只能在父子進程里使用。如果兩個沒有關系的進程要通信,就只能使用命名管道,最簡單的代碼這里:
pwrite.py
import os fd = os.open('pipetest',os.O_NONBLOCK | os.O_CREAT | os.O_RDWR) os.write(fd,"hello")
pread.py
import os fd = os.open('pipetest',os.O_RDONLY) s = os.read(fd,5) print s
apue里說匿名管道只能在父子進程里使用。如果兩個沒有關系的進程要通信,就只能使用命名管道,最簡單的代碼這里:
pwrite.py
import os fd = os.open('pipetest',os.O_NONBLOCK | os.O_CREAT | os.O_RDWR) os.write(fd,"hello")
pread.py
import os fd = os.open('pipetest',os.O_RDONLY) s = os.read(fd,5) print s
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。