4-30 700 views
linux pipe 读写分开,读的只能读,写的只能写,写什么,读到的就是什么
int msgpipe[2];
if (pipe(msgpipe)) {
LOG_INFO("could not create pipe: %s", strerror(errno));
return NULL;
}
int8_t cmdr;
int8_t cmdw = 9;
write(msgpipe[1], &cmdw, sizeof(cmdw));
read( msgpipe[0], &cmdr, sizeof(cmdr));