/* Work around printf() being unsafe in signals: */ #define SIGNAL_BUF_LEN 1000 char signal_message_buffer[SIGNAL_BUF_LEN]; void sig_print(char *msg)
{ int left = SIGNAL_BUF_LEN - strlen(signal_message_buffer) - 1;
/* Print any messages produced by the signal code: */
printf("%s", signal_message_buffer); /* *Resetthebuffertomakesureanyfutureprinting *onlyoutputsnewmessages:
*/
signal_message_buffer[0] = '\0';
if (noperm_errs)
fatal_error("saw %d errors in noperm signal handler\n", noperm_errs);
parent = fork(); if (parent < 0) { /* fork() failed */
fatal_error("fork");
} elseif (parent > 0) { int status; /* fork() succeeded. Now in the parent. */
wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status))
fatal_error("arch_prctl test parent exit"); return;
} /* fork() succeeded. Now in the child . */
printf("[RUN]\tCheck ARCH_REQ_XCOMP_PERM around process fork() and sigaltack() test.\n");
printf("\tFork a child.\n");
child = fork(); if (child < 0) {
fatal_error("fork");
} elseif (child > 0) { int status;
wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status))
fatal_error("arch_prctl test child exit");
_exit(0);
}
/* *Thepermissionrequestshouldfailwithoutan *XTILEDATA-compatiblesignalstack
*/
printf("\tTest XCOMP_PERM at child.\n");
validate_xcomp_perm(FAIL_EXPECTED);
/* *SetupanXTILEDATA-compatiblesignalstackand *alsoobtainpermissiontopopulateXTILEDATA.
*/
printf("\tTest dynamic sigaltstack at child:\n");
test_dynamic_sigaltstack();
/* Ensure that XTILEDATA can be populated. */
printf("\tTest XCOMP_PERM again at child.\n");
validate_xcomp_perm(SUCCESS_EXPECTED);
printf("\tFork a grandchild.\n");
grandchild = fork(); if (grandchild < 0) { /* fork() failed */
fatal_error("fork");
} elseif (!grandchild) { /* fork() succeeded. Now in the (grand)child. */
printf("\tTest XCOMP_PERM at grandchild.\n");
/* *Ensurethatthegrandchildinherited *permissionandacompatiblesigaltstack:
*/
validate_xcomp_perm(SUCCESS_EXPECTED);
} else { int status; /* fork() succeeded. Now in the parent. */
wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status))
fatal_error("fork test grandchild");
}
child = fork(); if (child < 0) { /* fork() failed */
fatal_error("fork");
} elseif (child > 0) { /* fork() succeeded. Now in the parent. */ int status;
wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status))
fatal_error("fork test child"); return;
} /* fork() succeeded. Now in the child. */
printf("[RUN]\tCheck tile data inheritance.\n\tBefore fork(), load tiledata\n");
load_rand_tiledata(stashed_xsave);
grandchild = fork(); if (grandchild < 0) { /* fork() failed */
fatal_error("fork");
} elseif (grandchild > 0) { /* fork() succeeded. Still in the first child. */ int status;
wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status))
fatal_error("fork test grand child");
_exit(0);
} /* fork() succeeded. Now in the (grand)child. */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.