Created
August 13, 2020 08:51
-
-
Save comex/58ba394588478bb1d506a998850b9436 to your computer and use it in GitHub Desktop.
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 <sys/types.h> | |
#include <sys/uio.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <signal.h> | |
#include <assert.h> | |
static void interrupted(int s) { | |
write(1, "interrupted\n", 12); | |
} | |
int main() { | |
char c[256]; | |
errno = 0; | |
assert(!signal(SIGINT, interrupted)); | |
ssize_t r = read(0, c, sizeof(c)); | |
printf("r=%zd errno=%d (%s)\n", r, errno, strerror(errno)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment