Pass the PID of the native host to the Wine hosts

We need this for our watchdog.
This commit is contained in:
Robbert van der Helm
2021-05-01 17:12:37 +02:00
parent 071bb157ad
commit 757fb6d372
4 changed files with 22 additions and 13 deletions
+2
View File
@@ -50,12 +50,14 @@ struct HostRequest {
PluginType plugin_type;
std::string plugin_path;
std::string endpoint_base_dir;
pid_t parent_pid;
template <typename S>
void serialize(S& s) {
s.object(plugin_type);
s.text1b(plugin_path, 4096);
s.text1b(endpoint_base_dir, 4096);
s.value4b(parent_pid);
}
};
+4 -2
View File
@@ -76,7 +76,8 @@ class PluginBridge {
HostRequest{
.plugin_type = plugin_type,
.plugin_path = info.windows_plugin_path.string(),
.endpoint_base_dir = sockets.base_dir.string()},
.endpoint_base_dir = sockets.base_dir.string(),
.parent_pid = getpid()},
sockets,
*config.group))
: std::unique_ptr<HostProcess>(
@@ -88,7 +89,8 @@ class PluginBridge {
.plugin_type = plugin_type,
.plugin_path =
info.windows_plugin_path.string(),
.endpoint_base_dir = sockets.base_dir.string()},
.endpoint_base_dir = sockets.base_dir.string(),
.parent_pid = getpid()},
sockets))),
has_realtime_priority(has_realtime_priority_promise.get_future()),
wine_io_handler([&]() {
+4
View File
@@ -83,6 +83,10 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context,
host_request.plugin_path,
#endif
host_request.endpoint_base_dir,
// We pass this process' process ID as an argument so we can run a
// watchdog on the Wine plugin host process that shuts down the
// sockets after this process shuts down
std::to_string(getpid()),
bp::env = plugin_info.create_host_env(),
bp::std_out = stdout_pipe,
bp::std_err = stderr_pipe
+12 -11
View File
@@ -39,20 +39,20 @@ __cdecl
main(int argc, char* argv[]) {
set_realtime_priority(true);
// We pass plugin format, the name of the VST2 plugin .dll file or VST3
// bundle to load, and the base directory for the Unix domain socket
// endpoints to connect to as the first two arguments of this process in
// `src/plugin/host-process.cpp`
if (argc < 4) {
std::cerr
<< "Usage: "
// We pass the plugin format, the name of the VST2 plugin .dll file or VST3
// bundle to load, the base directory for the Unix domain socket endpoints
// to connect to and the process ID of the process the native plugin is
// being hosted in as arguments for yabridge-host.exe
if (argc < 5) {
std::cerr << "Usage: "
#ifdef __i386__
<< yabridge_individual_host_name_32bit
<< yabridge_individual_host_name_32bit
#else
<< yabridge_individual_host_name
<< yabridge_individual_host_name
#endif
<< " <plugin_type> <plugin_location> <endpoint_base_directory>"
<< std::endl;
<< " <plugin_type> <plugin_location> "
"<endpoint_base_directory> <parent_pid>"
<< std::endl;
return 1;
}
@@ -61,6 +61,7 @@ __cdecl
const PluginType plugin_type = plugin_type_from_string(plugin_type_str);
const std::string plugin_location(argv[2]);
const std::string socket_endpoint_path(argv[3]);
const pid_t parent_pid = std::stoi(argv[4]);
std::cout << "Initializing yabridge host version " << yabridge_git_version
#ifdef __i386__