Created
February 24, 2014 16:58
-
-
Save bernerdschaefer/9192216 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <sched.h> | |
#include <stdio.h> | |
int _start_container(void *arg) | |
{ | |
return execl("/bin/bash", "bash", "-c", "echo $$", (char*) NULL); | |
} | |
int main(int argc, char *argv[]){ | |
int pid; | |
// We don't share memory with the parent, so just start growing the stack | |
// from here. | |
char child_stack[1]; | |
pid = clone( | |
_start_container, | |
child_stack, | |
CLONE_NEWPID, | |
0 | |
); | |
waitpid(pid, NULL, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment