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删除。