-
-
Save bnoordhuis/0030933d015d1e77ae04 to your computer and use it in GitHub Desktop.
dup() is per filedes, not per fd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
int fd = dup(0); | |
printf("O_NONBLOCK=%d\n", O_NONBLOCK & fcntl(0, F_GETFL)); | |
fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL)); | |
printf("O_NONBLOCK=%d\n", O_NONBLOCK & fcntl(0, F_GETFL)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment