Opened 13 years ago
Closed 12 years ago
#3921 closed Bugs (fixed)
Boost unit test & signals on linux
Reported by: | Owned by: | Gennadiy Rozental | |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | test |
Version: | Boost 1.40.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Dears,
The code below is working in the normal executable, but not in the test framework. The problem was very hard to find, because Linux tool are allowed to change order of the process execution.
Generally the problem is caused by signal monitor from the test framework. After fork() something happens (execlp) and then child process when exiting emits SIGCHLD, this signal normally reaches parent process. In the boost unit test signal monitor catches it, but not re-emits, so parent process hangs.
for testing you may use ::std::string const process_name ("ls -al");
pid_t const pid = fork(); if (pid < 0) {
error = -1;
} else {
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n'; if (pid == 0) child {
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n'; ::boost::int32_t const ret (execlp (process_name.c_str(), process_name.c_str(), NULL));
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n'; do not flush stdout _exit(127);
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n';
} else {
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n'; ignore waiting because we need to continue without waiting
int const wt = waitpid(pid, NULL, WUNTRACED | WCONTINUED); int const wt = waitpid(pid, NULL, 0);
::std::cerr << "wt = " << wt << '\n';
if (wt < 0) {
::std::cerr << PRETTY_FUNCTION << ' ' << LINE << '\n';
}
}
}
Trunk Boost.Test doesn't catch SIGCHLD, as of [57995]. See also #3664.