当前位置: 技术问答>linux和unix
Linux 线程之间用管道通信,出了个比较2的问题,贴代码,大家瞧瞧啊
来源: 互联网 发布时间:2017-03-29
本文导语: #include #include #include #include #include #include #include using namespace std; int fd[2]= {-1, -1}; typedef struct Message { unsigned int command; char ch; }Msg; bool isNotEmpty(int fdR) { struct pollfd pfd; pfd.fd = fd[0]; ...
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int fd[2]= {-1, -1};
typedef struct Message
{
unsigned int command;
char ch;
}Msg;
bool isNotEmpty(int fdR)
{
struct pollfd pfd;
pfd.fd = fd[0];
pfd.events = POLLIN;
pfd.revents = 0;
if(pfd.fd