1
我正在运行cygwin并使用pselect监视子进程的套接字和filedescriptors。pselect cygwin上的FD_ISSET问题
根据我在这里找到的一些示例http://www.linuxprogrammingblog.com/code-examples/using-pselect-to-avoid-a-signal-race和手册页pselect应该返回在掩码字段(http://linux.die.net/man/2/pselect)中设置的文件描述符的数量。
现在,当我连接到我的服务器pselect返回,这很好。但是,当我使用FD_ISSET测试的filedescriptors他们总是返回true:
FD_ZERO(&readers);
FD_ZERO(&writers);
FD_ZERO(&exceptions);
FD_SET(fileno(stdin), &readers);
FD_SET(socket, &readers);
pret = pselect(FD_SETSIZE, &readers, &writers, &exceptions, NULL, &mSignalMask);
,&读者,作家&,&例外,NULL,& mSignalMask);
if(pret <= 0)
{
// ignore for now
continue;
}
if(FD_ISSET(fileno(stdin), &readers))
{
string s;
cin >> s;
cout << "stdin: " << s << endl; // blocks because the code always gets here even when
// pselect returns because of a childsignal without any data.
continue;
}
if(FD_ISSET(socket, &readers))
{
accept(); // blocks because the code always gets here even when
// pselect returns because of a childsignal without any data.
cout << "task created connection from " <<task->getClientHost() << endl;
continue;
}