Commit 16fb1824 for tesseract
commit 16fb182476ebf26e7574135a83e4cf1917f4fcc2
Author: Ramya-9353 <ramya@digiscrypt.com>
Date: Fri Oct 9 15:43:40 2026 +0530
Exit child process when execvp fails (#4577)
SVSync::StartProcess forks, and the child builds an argv vector and
calls execvp. execvp returns only when the exec itself failed, and the
child then fell through the end of the else branch and returned from
StartProcess, so it carried on down the parent's code path. With a
missing or non-executable ScrollView launcher that leaves two processes
running the same pipeline over the same inherited descriptors, and no
diagnostic for the failed exec.
Report the failure with perror and end the child with
_exit(EXIT_FAILURE) immediately after execvp returns. _exit is used
rather than exit so the child does not flush the stdio buffers it
inherited from the parent a second time, and does not run the parent's
atexit handlers.
diff --git a/src/viewer/svutil.cpp b/src/viewer/svutil.cpp
index c834f52a..58fc9bc3 100644
--- a/src/viewer/svutil.cpp
+++ b/src/viewer/svutil.cpp
@@ -110,6 +110,9 @@ void SVSync::StartProcess(const char *executable, const char *args) {
}
argv[argc] = nullptr;
execvp(executable, argv.get());
+ // execvp returns only if execution failed.
+ perror(executable);
+ _exit(EXIT_FAILURE);
}
# endif
}