-
Notifications
You must be signed in to change notification settings - Fork 5
Race condition #21
Copy link
Copy link
Open
Description
blog/way_too_many_ways_to_wait_for_a_child_process_with_a_timeout.html
Lines 336 to 360 in ebb19f4
| int child_pid = fork(); | |
| if (-1 == child_pid) { | |
| return errno; | |
| } | |
| if (0 == child_pid) { // Child | |
| argv += 1; | |
| if (-1 == execvp(argv[0], argv)) { | |
| return errno; | |
| } | |
| __builtin_unreachable(); | |
| } | |
| sigset_t sigset = {0}; | |
| sigemptyset(&sigset); | |
| sigaddset(&sigset, SIGCHLD); | |
| siginfo_t siginfo = {0}; | |
| struct timespec timeout = { | |
| .tv_sec = wait_ms / 1000, | |
| .tv_nsec = (wait_ms % 1000) * 1000 * 1000, | |
| }; | |
| int sig = sigtimedwait(&sigset, &siginfo, &timeout); |
SIGCHLD may come after fork() and before sigtimedwait().
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels