Based on what I understood from the link in my comment, I would try something like this (the select() parameters and other function calls can be completely different):
if (select(sock 1, &input_mask, NULL, NULL, NULL) < 0) { fprintf(stderr, "select() failed: %s\n", strerror(errno)); exit_nicely(conn); } PQconsumeInput(conn); while (PQisBusy(conn) != 0) { } while (PGresult* res = PQgetResult(conn)) { }
source share