Fix file_handler process race condition

The current process could be waited both by run_file_handler() and
file_handler_stop().

To avoid the race condition, wait the process without closing, then
close with mutex locked.
This commit is contained in:
Romain Vimont
2021-01-22 19:20:30 +01:00
parent 6a50231698
commit 7afd149f4b
4 changed files with 18 additions and 12 deletions

View File

@@ -3,12 +3,12 @@
#include "log.h"
bool
process_check_success(process_t proc, const char *name) {
process_check_success(process_t proc, const char *name, bool close) {
if (proc == PROCESS_NONE) {
LOGE("Could not execute \"%s\"", name);
return false;
}
exit_code_t exit_code = process_wait(proc, true);
exit_code_t exit_code = process_wait(proc, close);
if (exit_code) {
if (exit_code != NO_EXIT_CODE) {
LOGE("\"%s\" returned with value %" PRIexitcode, name, exit_code);

View File

@@ -61,7 +61,7 @@ process_close(process_t pid);
// convenience function to wait for a successful process execution
// automatically log process errors with the provided process name
bool
process_check_success(process_t proc, const char *name);
process_check_success(process_t proc, const char *name, bool close);
#ifndef _WIN32
// only used to find package manager, not implemented for Windows