Anche il piu' semplice dei programmi C dovrebbe avere il suo Makefile ----Makefile------------------- CFLAGS=-Wall -std=c99 myshell: myshell.o gcc $(CFLAGS) myshell.o -o myshell -----myshell.c----------------- #include #include #include #include #include #include #define MAX_LINE 1024 char line[MAX_LINE]; void print_prompt() { printf("myshell> "); } void chop_newline_at_end(char *s) { s[strlen(s)-1] = '\0'; } void read_command() { char * read = fgets(line, MAX_LINE, stdin); if (!read) exit(0); chop_newline_at_end(line); } void execute_command() { execlp(line, line, NULL); // se siamo qui la execlp ha fallito! perror(line); } void wait_for_child() { int status; wait(&status); printf("child returned with status %d\n", status); } int main() { while (1) { print_prompt(); read_command(); pid_t pid = fork(); if (0 == pid) { execute_command(); } else { wait_for_child(); } } }