-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update session 4 with working instructions.
- Loading branch information
Zed A. Shaw
committed
Jul 20, 2015
1 parent
55e8186
commit 8c960d1
Showing
2 changed files
with
67 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#define _GNU_SOURCE | ||
#include <sys/types.h> | ||
#include <sys/wait.h> | ||
#include <stdio.h> | ||
#include <sched.h> | ||
#include <signal.h> | ||
#include <unistd.h> | ||
|
||
#define STACK_SIZE (1024 * 1024) | ||
|
||
static char child_stack[STACK_SIZE]; | ||
char* const child_args[] = { | ||
"/bin/bash", | ||
NULL | ||
}; | ||
|
||
int child_main(void* arg) | ||
{ | ||
sethostname("In Namespace", 12); | ||
execv(child_args[0], child_args); | ||
return 1; | ||
} | ||
|
||
int main() | ||
{ | ||
int child_pid = clone(child_main, child_stack+STACK_SIZE, | ||
CLONE_NEWUTS | SIGCHLD, NULL); | ||
waitpid(child_pid, NULL, 0); | ||
return 0; | ||
} | ||
|
This file contains 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