repo.or.cz
/
eleutheria.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Add comments for how to compile
[eleutheria.git]
/
ipc
/
fork_execlp.c~
blob
24d224269331687949a3264740e0748533c895bf
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <unistd.h>
4
#include <sys/wait.h>
5
6
int main(void)
7
{
8
pid_t pid;
9
int retval;
10
11
if ((pid = fork()) < 0) { /* fork error */
12
perror("fork");
13
exit(EXIT_FAILURE);
14
}
15
16
else if (pid > 0) /* parent process */
17
wait(&retval);
18
19
else if (pid == 0) { /* child process */
20
if (execlp("date", "date", (char *)0) < 0) {
21
perror("execlp");
22
exit(EXIT_FAILURE);
23
}
24
}
25
26
return EXIT_SUCCESS;
27
}