title: C++: Timeout for an external application call
body: <p>For a c++ program I'm working on, I have to call an external application to do some operations. I can't modify the application. This operations may take too much time so I have to add a timeout. I tried using system() and boost threads</p>
  
  <pre><code>int main() 
  {
    [...]
  
    boost::thread t(function1);
    t.timed_join(boost::posix_time::seconds(10));
  
    [...]
  
    return 0;
  }
  
  void function1()
  {
    system("external application");
  }
  </code></pre>
  
  <p>but when I return to the main 10 seconds later, the external application is still running in background.
  Using exec() instead of system() nothing works because I "lose" the main. What can I do?
  I'm on Linux.</p>