This commit is contained in:
2021-03-01 16:39:46 +01:00
parent 0453269f24
commit 5b651516d2
35 changed files with 1013 additions and 14 deletions

View File

@@ -0,0 +1,13 @@
all: p5 p6 p7
p5:
gcc -o p5 p5.c
p6:
gcc -o p6 p6.c
p7:
gcc -o p7 p7.c
clean:
rm -f p5 p6 p7

View File

@@ -0,0 +1,23 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
int pid;
pid = fork();
if (pid == 0)
{ // child proc looping endlessly
printf("%d: child ...\n", getpid());
for(;10;);
}
else
{ // parent proc
printf("%d: parent; child pid: %d \n", getpid(), pid);
wait(NULL); // for child termination
printf("%d: parent after wait ... terminating\n", getpid());
}
}

View File

@@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("p6: calling getchar()\n");
getchar();
}

View File

@@ -0,0 +1,8 @@
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("p7: calling sleep()\n");
sleep(100);
}