Add comments for how to compile
[eleutheria.git] / ipc / fork_execlp.c~
blob24d224269331687949a3264740e0748533c895bf
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <sys/wait.h>
6 int main(void)
8     pid_t pid;
9     int retval;
11     if ((pid = fork()) < 0) {  /* fork error */
12         perror("fork");
13         exit(EXIT_FAILURE);
14     }
16     else if (pid > 0)          /* parent process */
17         wait(&retval);
19     else if (pid == 0) {       /* child process */
20         if (execlp("date", "date", (char *)0) < 0) {
21             perror("execlp");
22             exit(EXIT_FAILURE);
23         }
24     }
26    return EXIT_SUCCESS;