• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // kills itself using poison
2 #define _GNU_SOURCE 1
3 #include <stdlib.h>
4 #include <sys/mman.h>
5 #include <stdio.h>
6 #include <unistd.h>
7 
8 #define MADV_POISON 100
9 
main(void)10 int main(void)
11 {
12 	int PS = getpagesize();
13 	char *ptr = mmap(NULL, PS, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_POPULATE, 0,0);;
14 	printf("ptr = %p\n", ptr);
15 	madvise(ptr, PS, MADV_POISON);
16 	printf("faulting\n");
17 	*ptr = 1;
18 	printf("waiting\n");
19 	sleep(100);
20 	return 0;
21 }
22