STL容器[34]

 
SERVER以读打开FIFO;
CLIENT以写打开FIFO;
SERVER关闭FIFO;
CLIENT向当前FIFO写数据,此时CLIENT获得一个SIGPIPE信号。如果忽略该信号,那么write将返回-1,ERRNO为EPIPE
 
向一个写打开,当对端已经关闭的
 
 
void doPIPE (int a)
{
std::cout << "A:" << a << std::endl;
}
 
int main()
{
std::cout << "PIPE_BUF:"    << PIPE_BUF << std::endl;
 
struct sigaction sig;
sigemptyset(&sig.sa_mask);
sig.sa_handler = doPIPE;
        sig.sa_flags = 0;
        sigaction(SIGPIPE, &sig, NULL);
 
MT_Fifo c2s;
 
c2s.open(C2S_FIFO, MT_Fifo::EM_WRITE);
 
std::cout << "c2s fd:" << c2s.fd() << std::endl;
 
sleep(10);
std::cout << "To Send:" << std::endl;
int iRet = c2s.write(" ", 1);
std::cout << "Ret:" << iRet << "|Errno:" << errno << "|" << strerror(errno) << std::endl;
 
return 0;
}
posted @ 2009-12-28 14:45  酱油和醋  阅读(187)  评论(0编辑  收藏  举报