Allow vfork

This commit is contained in:
Alexey Milovidov 2021-12-19 08:53:35 +03:00
parent fb5b1c3d6a
commit d6ece47b7f

View File

@ -155,12 +155,17 @@ std::unique_ptr<ShellCommand> ShellCommand::executeImpl(
{ {
logCommand(filename, argv); logCommand(filename, argv);
#if !defined(USE_MUSL)
/** Here it is written that with a normal call `vfork`, there is a chance of deadlock in multithreaded programs, /** Here it is written that with a normal call `vfork`, there is a chance of deadlock in multithreaded programs,
* because of the resolving of symbols in the shared library * because of the resolving of symbols in the shared library
* http://www.oracle.com/technetwork/server-storage/solaris10/subprocess-136439.html * http://www.oracle.com/technetwork/server-storage/solaris10/subprocess-136439.html
* Therefore, separate the resolving of the symbol from the call. * Therefore, separate the resolving of the symbol from the call.
*/ */
static void * real_vfork = dlsym(RTLD_DEFAULT, "vfork"); static void * real_vfork = dlsym(RTLD_DEFAULT, "vfork");
#else
/// If we use Musl with static linking, there is no dlsym and no issue with vfork.
static void * real_vfork = reinterpret_cast<void *>(&vfork);
#endif
if (!real_vfork) if (!real_vfork)
throwFromErrno("Cannot find symbol vfork in myself", ErrorCodes::CANNOT_DLSYM); throwFromErrno("Cannot find symbol vfork in myself", ErrorCodes::CANNOT_DLSYM);