A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
22
Task/Fork/C/fork-1.c
Normal file
22
Task/Fork/C/fork-1.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <err.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (!(pid = fork())) {
|
||||
usleep(10000);
|
||||
printf("\tchild process: done\n");
|
||||
} else if (pid < 0) {
|
||||
err(1, "fork error");
|
||||
} else {
|
||||
printf("waiting for child %d...\n", (int)pid);
|
||||
printf("child %d finished\n", (int)wait(0));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
3
Task/Fork/C/fork-2.c
Normal file
3
Task/Fork/C/fork-2.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
waiting for child 3604...
|
||||
child process: done
|
||||
child 3604 finished
|
||||
Loading…
Add table
Add a link
Reference in a new issue