Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created February 24, 2014 16:58
Show Gist options
  • Save bernerdschaefer/9192216 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/9192216 to your computer and use it in GitHub Desktop.
#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