repo.or.cz
/
lcapit-junk-code.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
lfs: Introduces lfs-chroot
[lcapit-junk-code.git]
/
clone.c
blob
7ae9fe9cac45fd9f58cc42a2dc5c0074a8a8e565
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <sched.h>
4
#include <sys/wait.h>
5
#include <sys/types.h>
6
7
#define UNUSED(x) (x = x)
8
#define STACK_SIZE 16
9
10
int
child
(
void
*
arg
)
11
{
12
UNUSED
(
arg
);
13
14
printf
(
"[child] Hello world!
\n
"
);
15
return
0
;
16
}
17
18
int
main
(
void
)
19
{
20
int
tid
;
21
char
stack
[
STACK_SIZE
];
22
23
tid
=
clone
(
child
, (
void
*)
stack
,
0
,
NULL
);
24
if
(
tid
<
0
) {
25
perror
(
"clone()"
);
26
exit
(
1
);
27
}
28
29
wait
(
NULL
);
30
31
printf
(
"[parent]: exiting
\n
"
);
32
return
0
;
33
}