mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-08 14:58:54 +00:00
![Riccardo Schirone](/assets/img/avatar_default.png)
This should fix a nasty issue with r2r, where tests never terminated. That was caused by the jq process waiting indefinitely for input from fd0, because the other end of the pipe was never closed. Indeed r2r_subprocess_start forks and closes known unnecessary opened fd in the child process, however it does not consider also all the other file descriptors that could have been created by other threads simultaneously. As fd are per-process and not per-thread, file descriptors created by other threads while doing e.g. pipe to spawn a separate jq process will clutter other threads (and following jq processes) as well. If two jq processes happen to keep a fd to the other end of the pipe for the fd0 of the other jq process, none of them terminates, thus they never close those spurious file descriptors, causing tests to hang. This tries to fix the issue by making sure only one thread at a time can start a subprocess. In this way no other FDs can be created while a thread is in the middle of r2r_subprocess_start.