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