#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
pid_t id1 = fork();
pid_t id2 = fork();
if (id1 > 0 && id2 > 0) {
printf("Parent Terminated\n"); } else {
pid_t id3 = fork();
if (id3 > 0) {
} else {
printf("Grandchild Terminated\n"); }
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzeXMvd2FpdC5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCkKewogICAgcGlkX3QgaWQxID0gZm9yaygpOwogICAgcGlkX3QgaWQyID0gZm9yaygpOwoKICAgIGlmIChpZDEgPiAwICYmIGlkMiA+IDApIHsKICAgICAgICBwcmludGYoIlBhcmVudCBUZXJtaW5hdGVkXG4iKTsKICAgIH0gZWxzZSB7CiAgICAgICAgcGlkX3QgaWQzID0gZm9yaygpOwogICAgICAgIGlmIChpZDMgPiAwKSB7CiAgICAgICAgICAgIHByaW50ZigiQ2hpbGQgVGVybWluYXRlZFxuIik7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcHJpbnRmKCJHcmFuZGNoaWxkIFRlcm1pbmF0ZWRcbiIpOwogICAgICAgICAgICBleGl0KDApOwogICAgICAgIH0KICAgIH0KICAgIHByaW50ZigiQnllXG4iKTsKICAgIHJldHVybiAwOwp9Cg==