boostorg / boost

Super-project for modularized Boost
https://github.com/boostorg/wiki/wiki/Getting-Started%3A-Overview
Boost Software License 1.0
7.02k stars 1.73k forks source link

[Linux] boost::process:: child ::wait_until is not thread-safe #824

Closed AlexeyZaharov closed 10 months ago

AlexeyZaharov commented 10 months ago

Hi! I faced with the problem that my process hangs up while it uses _waituntil() of child::process. So I watched boost code and find that boost::process::child::wait_until is not thread-safe

  1. _struct signal_interceptort is used for setting custom reaction on signal with using system ::signal. So _handlerfunc is a new handler and _sigchldhandler is setting for previous handler
  2. The problem is that signal handler - atribut of the process, not thread, so if the next thread call ::signal then _sigchldhandler is setting for _handlerfunc
  3. Which thread will be used for handle signal is undefined. So thread with _sigchldhandler == _handlerfunc can be used! And this cause infinite loop
  4. You can face with the problem in this code, which uses problem part of _waituntil. (On my system signals are handled by main thread). Also attach out of the programm bug_wait_until.cpp.txt out.txt

So can you update your documentation with this note please?

AlexeyZaharov commented 10 months ago

Close this issue and open in right place