Informatik/Assets/Betriebssysteme_uebung/u2-anlage/u2-a1-anlage/p3.c

23 lines
401 B
C
Raw Normal View History

2021-03-01 15:39:46 +00:00
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
if (fork() == 0)
{ // child proc
printf("%d: child created by parent %d; executing 'p4'...\n", getpid(), getppid());
execl("p4", "p4", NULL);
}
else
{ // parent proc
printf("%d: parent process\n", getpid());
}
fork();
printf("%d: terminating\n", getpid());
wait(NULL);
}