int getchild(int group, int child, int children) { int pid; pid = FORK_OR_VFORK(); if (pid < 0) { massmurder(); /* kill the kids */ tst_brkm(TBROK, cleanup, "\tFork failed (may be OK if under stress)"); tst_exit(); } else if (pid == 0) { /* child does this */ switch (children % NCHILD) { case 0: #ifdef UCLINUX if (self_exec(argv0, "nd", 1, nfiles) < 0) { massmurder(); tst_brkm(TBROK, cleanup, "\tself_exec failed"); tst_exit(); } #else dochild1(); /* create existing directories */ #endif break; /* so lint won't complain */ case 1: #ifdef UCLINUX if (self_exec(argv0, "n", 2) < 0) { massmurder(); tst_brkm(TBROK, cleanup, "\tself_exec failed"); tst_exit(); } #else dochild2(); /* remove nonexistant directories */ #endif break; case 2: #ifdef UCLINUX if (self_exec(argv0, "nd", 3, group) < 0) { massmurder(); tst_brkm(TBROK, cleanup, "\tself_exec failed"); tst_exit(); } #else dochild3(group); /* create/delete directories */ #endif break; default: tst_brkm(TFAIL, cleanup, "Test not inplemented for child %d", child); exit(1); break; } exit(1); /* If child gets here, something wrong */ } pidlist[children] = pid; return 0; }
void dochild3_uclinux(void) { /* Set up to catch SIGTERM signal */ if (signal(SIGTERM, term) == SIG_ERR) { tst_brkm(TFAIL, cleanup, "Error setting up SIGTERM signal, ERRNO = %d", errno); } dochild3(group_uclinux); }