This is very strange.
If you change that line to the following (removing $msg)::
print STDERR $pkg . " (" . $$ . "): ";
...it begins to work properly.
Before that line if you add:
die $msg;
....it also hangs.
However if you add:
die $msg;
...before:
# Remove windows linefeeds (breaks unix terminals).
$msg =~ s/\r//g unless ($^O eq 'MSWin32');
...then it works.
This must be something to do with the contents of $msg.
If you change that line to the following (removing $msg)::
print STDERR $pkg . " (" . $$ . "): ";
...it begins to work properly.
Before that line if you add:
die $msg;
....it also hangs.
However if you add:
die $msg;
...before:
# Remove windows linefeeds (breaks unix terminals).
$msg =~ s/\r//g unless ($^O eq 'MSWin32');
...then it works.
This must be something to do with the contents of $msg.