1 #include <rudiments/process.h>
2 #include <rudiments/stdio.h>
3 
main(int argc,const char ** argv)4 int main(int argc, const char **argv) {
5 
6 	// see if fork() is supported and exit if it's not...
7 	if (!process::supportsFork()) {
8 		stdoutput.write("sorry, fork() not supported\n");
9 		process::exit(1);
10 	}
11 
12 	// fork the process
13 	pid_t	pid=process::fork();
14 
15 	if (pid) {
16 		// the parent process will run this code...
17 		stdoutput.write("I am the parent.  ");
18 		stdoutput.printf("The child's process id is %d\n",pid);
19 		process::exit(0);
20 	} else {
21 		// the child process will run this code...
22 		stdoutput.write("I am the child.  ");
23 		stdoutput.printf("My process id is %d\n",
24 						process::getProcessId());
25 		stdoutput.write("and I'm running \"ls -l /\"...\n");
26 
27 		// execute the command:  ls -l /
28 		const char * const arguments[]={"ls","-l","/",NULL};
29 		process::exec("ls",arguments);
30 	}
31 }
32