Skip to content

Instantly share code, notes, and snippets.

@cwen0
Forked from ethercflow/hook_read.c
Created July 2, 2018 07:34
Show Gist options
  • Save cwen0/eee60159277cf027eeeb33be3deb95b1 to your computer and use it in GitHub Desktop.
Save cwen0/eee60159277cf027eeeb33be3deb95b1 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <dlfcn.h>
ssize_t read(int fd, void *buf, size_t count) {
ssize_t (*origin_read)(int, void*, size_t) = dlsym(RTLD_NEXT, "read");
sleep(5);
printf("read sleep 5s\n");
return origin_read(fd, buf, count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment