I'm learning about operating systems on The MINIX Book (Tanembaum), and one of the exercises I went through is to build a VERY simple shell.
For this, the book provides this piece of code:
#define TRUE 1
while (TRUE) {
type_prompt();
read_command(command, parameters);
if (fork() != 0) {
waitpid(-1, &status, 0);
} else {
execve(command, parameters, 0);
}
}
This is not the entire C program (obviously) and I need to declare some variables and write some functions by my own. But fork()
, for example, is a system call (as said in the book, it should be POSIX compatible).
What #include
directives my program should have to use them, assuming I am compiling this program on MINIX already (and all other functions that I wrote are in this same .c file)? How does it work to use Linux system calls on C programs?
Thanks!
A google search of man fork
will show the linux man page and it indicates that it needs:
#include <unistd.h>