Skip to content

Commit

Permalink
dlopen /System/Library/Frameworks/Foundation.framework/Foundation to …
Browse files Browse the repository at this point in the history
…initialize Objective-C APIs before fork(2)
  • Loading branch information
skaji committed Apr 28, 2024
1 parent ab476fe commit a976ad8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/App/cpm/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ sub cmd_install {
sub install {
my ($self, $master, $worker, $num) = @_;

if ($num > 1
&& $^O eq "darwin"
&& !exists $ENV{OBJC_DISABLE_INITIALIZE_FORK_SAFETY}
&& !$self->{_darwin_fixed}
) {
my $lib = "/System/Library/Frameworks/Foundation.framework/Foundation";
$master->{logger}->log("dlopen $lib to initialize Objective-C APIs before fork(2)");
require DynaLoader;
DynaLoader::dl_load_file $lib;
$self->{_darwin_fixed} = 1;
}

my @task = $master->get_task;
Parallel::Pipes::App->run(
num => $num,
Expand Down

0 comments on commit a976ad8

Please sign in to comment.