Skip to content

Instantly share code, notes, and snippets.

@comex
Created August 13, 2020 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comex/58ba394588478bb1d506a998850b9436 to your computer and use it in GitHub Desktop.
Save comex/58ba394588478bb1d506a998850b9436 to your computer and use it in GitHub Desktop.
#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