blob: 78b1a533f17686a3fd246ce0ef6b96f51e796a67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <stdio.h>
#include <error.h>
#include <unistd.h>
int wait(int32_t *status)
{
return (waitpid(0, status));
}
int spawn(uint_t prog, char **args)
{
int32_t pid;
pid = fork();
if (pid != 0) {
// failure, or we are the parent
return (pid);
}
// we are the child
pid = getpid();
// child inherits parent's priority level
exec(prog, args);
// uh-oh....
fprintf(stderr, "Child %d exec() #%u failed\n", pid, prog);
exit(EXIT_FAILURE);
}
|