Run cbm_extract_file in a forked child; true if the child died by signal. * Mirrors tests/test_lang_contract.c. On Windows run in-process (a genuine * crash there aborts the runner — hard, visible failure). */
| 415 | * Mirrors tests/test_lang_contract.c. On Windows run in-process (a genuine |
| 416 | * crash there aborts the runner — hard, visible failure). */ |
| 417 | static bool so_extract_crashes(const char *content, CBMLanguage lang, const char *relpath) { |
| 418 | #if defined(_WIN32) |
| 419 | CBMFileResult *r = |
| 420 | cbm_extract_file(content, (int)strlen(content), lang, "so", relpath, 0, NULL, NULL); |
| 421 | if (r) { |
| 422 | cbm_free_result(r); |
| 423 | } |
| 424 | return false; |
| 425 | #else |
| 426 | fflush(NULL); |
| 427 | pid_t pid = fork(); |
| 428 | if (pid < 0) { |
| 429 | return false; |
| 430 | } |
| 431 | if (pid == 0) { |
| 432 | CBMFileResult *r = |
| 433 | cbm_extract_file(content, (int)strlen(content), lang, "so", relpath, 0, NULL, NULL); |
| 434 | if (r) { |
| 435 | cbm_free_result(r); |
| 436 | } |
| 437 | _exit(0); |
| 438 | } |
| 439 | int status = 0; |
| 440 | (void)waitpid(pid, &status, 0); |
| 441 | return WIFSIGNALED(status); |
| 442 | #endif |
| 443 | } |
| 444 | |
| 445 | #if !defined(_WIN32) |
| 446 | /* Child-side alarm handler: a clean exit on the deadline — never reached on |
no test coverage detected