C valoda.Kā dabūt vienam child procesam apakš procesu, ņemot vērā ka iepriekšējais process ir lielāks un atgriežas pie iepriekšējā.
Pagaidam kods ir šāds:
#include <stdio.h>
#include <stdlib.h> int main ()
{
int pid, pid3,pid4, status, died;
switch (pid = fork())
{
case -1: printf("Can't fork\n");
exit(-1);
case 0:
printf("I am a child\n");
exit(3);
default: died = wait(& status);
}
printf("Child was %d\n",pid);
printf("%d died\n",died);
printf("Exit value %d\n",status >> 8);
printf("Exit status %d\n",status >> 7); switch (pid3 = fork())
{
case -1:
printf("Can't fork\n");
exit(-1);
case 0:
printf("I am a child3\n");
exit(5);
default: died = wait(& status); }
printf("Child was %d\n",pid3);
printf("%d died\n",died);
printf("Exit value %d\n",status >> 8);
printf("Exit status %d\n",status >> 7); exit(0);
}