summaryrefslogtreecommitdiffstats
path: root/shell/beispiele/fork_signal/fork.c
diff options
context:
space:
mode:
authorStefan Zabka <zabkaste@hu-berlin.de>2020-05-24 12:19:52 +0200
committerStefan Zabka <zabkaste@hu-berlin.de>2020-05-24 12:19:52 +0200
commit04576dc2a3f761eb041b808b56f13a58052e7655 (patch)
treec6bed6db34e29f0dec0c844fbc931b3dd4fab8db /shell/beispiele/fork_signal/fork.c
parent65966ded0cc15c5966c6568cf0ff2f2bbe1fc29a (diff)
downloadbetriebssysteme-04576dc2a3f761eb041b808b56f13a58052e7655.tar.gz
betriebssysteme-04576dc2a3f761eb041b808b56f13a58052e7655.zip
Moved back to 02_exercise
Diffstat (limited to 'shell/beispiele/fork_signal/fork.c')
-rw-r--r--shell/beispiele/fork_signal/fork.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/shell/beispiele/fork_signal/fork.c b/shell/beispiele/fork_signal/fork.c
deleted file mode 100644
index b144577..0000000
--- a/shell/beispiele/fork_signal/fork.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int main(int argc, const char* argv[]) {
- pid_t pid;
- int h;
- int count;
-
- if (argc < 2) {
- printf("Usage: ./fork process#\n");
- return 0;
- }
-
- count = atoi(argv[1]) - 1;
- printf("Process#: %d\n", count + 1);
- printf("Parent started\n");
-
- pid = 1;
- for (h = 0; h < count; ++h) {
- if ((pid = fork()) < 0)
- printf("fork error\n");
- else if (pid == 0) {
- printf("Child %d started\n", h);
- sleep(1);
- printf("Child %d finished\n", h);
- exit(0);
- }
- }
-
- printf("Parent waiting\n");
- for (h = 0; h < count; ++h) {
- wait(NULL);
- }
- printf("Parent finished\n");
- return EXIT_SUCCESS;
-}