[Boost-bugs] [Boost C++ Libraries] #3921: Boost unit test & signals on linux

Subject: [Boost-bugs] [Boost C++ Libraries] #3921: Boost unit test & signals on linux
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-11 13:15:35


#3921: Boost unit test & signals on linux
-------------------------------+--------------------------------------------
 Reporter: habdank@… | Owner: rogeeff
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: test
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: |
-------------------------------+--------------------------------------------
 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';
         }
     }
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3921>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC