1 when the probe passed; otherwise `why` says what happened. */
| 11409 | |
| 11410 | /* 1 when the probe passed; otherwise `why` says what happened. */ |
| 11411 | static int deep_probe_passed(deep_probe_fn fn, char *why, size_t why_len) { |
| 11412 | #if defined(_WIN32) |
| 11413 | int rc = deep_probe_on_worker_stack(fn); |
| 11414 | if (rc != 0) { |
| 11415 | snprintf(why, why_len, "probe returned %d", rc); |
| 11416 | } |
| 11417 | return rc == 0; |
| 11418 | #else |
| 11419 | fflush(NULL); |
| 11420 | pid_t pid = fork(); |
| 11421 | if (pid < 0) { |
| 11422 | snprintf(why, why_len, "fork failed"); |
| 11423 | return 0; |
| 11424 | } |
| 11425 | if (pid == 0) { |
| 11426 | int rc = deep_probe_on_worker_stack(fn); |
| 11427 | fflush(NULL); |
| 11428 | _exit(rc); |
| 11429 | } |
| 11430 | int status = 0; |
| 11431 | (void)waitpid(pid, &status, 0); |
| 11432 | if (WIFSIGNALED(status)) { |
| 11433 | snprintf(why, why_len, |
| 11434 | "extraction killed by signal %d on a worker-sized stack: a walker recursed once " |
| 11435 | "per nesting level", |
| 11436 | WTERMSIG(status)); |
| 11437 | return 0; |
| 11438 | } |
| 11439 | if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { |
| 11440 | snprintf(why, why_len, "probe returned %d", WIFEXITED(status) ? WEXITSTATUS(status) : -1); |
| 11441 | return 0; |
| 11442 | } |
| 11443 | return 1; |
| 11444 | #endif |
| 11445 | } |
| 11446 | |
| 11447 | /* head, `levels` times '(', core, `levels` times ')', tail. *core_at receives |
| 11448 | * the byte offset of core. */ |
no test coverage detected