Skip to content

Instantly share code, notes, and snippets.

@indutny
Created July 6, 2012 14:55
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 indutny/4083bddd75c2078c1efc to your computer and use it in GitHub Desktop.
Save indutny/4083bddd75c2078c1efc to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <mach/task.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
#include <time.h>
int main(void)
{
void* raw = mmap(NULL,
1024,
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED,
-1,
0);
if (raw == MAP_FAILED) abort();
memset(raw, 61, 1023);
((char*)raw)[1022]=62;
((char*)raw)[1023]=0;
int pid;
pid = fork();
if (pid) {
fprintf(stdout, "%s\n", (char*) raw);
while(1) {
}
} else {
fprintf(stdout, "%s\n", (char*) raw);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment