toaruos/userspace/shmcrash2.c
Kevin Lange 07955c83c6 Fix dozens of build warnings and other oddities.
* Finally bring syscall.h up to speed and include all syscalls in the
  syscall module of the C library.
* Remove the third-party obfuscated C demos (we have nyancat, good
  enough)
* Fix userspace apps to build without complaining about undeclared
  strtok_r by disable __STRICT_ANSI__
* Fix .eh_frame by including the proper stuff with libgcc.
2012-09-04 20:27:49 -07:00

33 lines
612 B
C

/*
* shmcrash2
*
* crashes!
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdint.h>
#include <syscall.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main (int argc, char ** argv) {
if (argc < 2) {
fprintf(stderr, "%s: expected argument\n", argv[0]);
return 1;
}
printf("(this should not crash; but the kernel should free the shm block)\n");
size_t size = 0x1000;
volatile char * shm = (char *)syscall_shm_obtain(argv[1], &size);
if (shm == NULL) {
return 1;
}
char * args[] = {"/bin/echo", "exec'd to echo\n", NULL};
execve(args[0], args, NULL);
return 5;
}