Skip to content

Commit

Permalink
Allocate memory before fork()
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGriffiths committed Sep 5, 2024
1 parent 864371b commit 0d39af8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/miral/launch_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace
{
void strip_mir_env_variables()
auto mir_env_variables() -> std::vector<std::string>
{
static char const mir_prefix[] = "MIR_";

Expand All @@ -51,10 +51,7 @@ void strip_mir_env_variables()
}
}

for (auto const& var : vars_to_remove)
{
unsetenv(var.c_str());
}
return vars_to_remove;
}
} // namespace

Expand All @@ -64,6 +61,8 @@ auto miral::launch_app_env(
mir::optional_value<std::string> const& x11_display,
miral::AppEnvironment const& app_env) -> pid_t
{
static auto const vars_to_remove = mir_env_variables();

pid_t pid = fork();

if (pid < 0)
Expand All @@ -73,7 +72,10 @@ auto miral::launch_app_env(

if (pid == 0)
{
strip_mir_env_variables();
for (auto const& var : vars_to_remove)
{
unsetenv(var.c_str());
}

if (x11_display)
{
Expand Down

0 comments on commit 0d39af8

Please sign in to comment.