int num_fds = select(max, &r, &w, &e, nullptr); // If there is data to be read on STDIN, then the number of // fds ready will be 3 instead of 2. Allow this case, but verify // every fd that is set.
ASSERT_TRUE(num_fds == 2 || num_fds == 3) << "Num fds returned " << num_fds;
ASSERT_TRUE(FD_ISSET(STDOUT_FILENO, &w));
ASSERT_TRUE(FD_ISSET(STDERR_FILENO, &w)); if (num_fds == 3) {
ASSERT_TRUE(FD_ISSET(STDIN_FILENO, &r));
}
FD_ZERO(&r);
FD_SET(fd, &r);
ASSERT_EQ(1, select(fd+1, &r, nullptr, nullptr, &tv)); // Both tv_sec and tv_nsec should have been updated.
ASSERT_EQ(0, tv.tv_sec);
ASSERT_NE(0, tv.tv_usec);
// If there is data to be read on STDIN, then the number of // fds ready will be 3 instead of 2. Allow this case, but verify // every fd that is set. int num_fds = pselect(max, &r, &w, &e, nullptr, &ss);
ASSERT_TRUE(num_fds == 2 || num_fds == 3) << "Num fds returned " << num_fds;
ASSERT_TRUE(FD_ISSET(STDOUT_FILENO, &w));
ASSERT_TRUE(FD_ISSET(STDERR_FILENO, &w)); if (num_fds == 3) {
ASSERT_TRUE(FD_ISSET(STDIN_FILENO, &r));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.