use strict;
use warnings;
-our $VERSION = '1.302015';
+our $VERSION = '1.302022';
-use base 'Test2::IPC::Driver';
+BEGIN { require Test2::IPC::Driver; our @ISA = qw(Test2::IPC::Driver) }
use Test2::Util::HashBase qw{tempdir event_id tid pid globals};
use File::Temp();
use Storable();
use File::Spec();
+use POSIX();
-use Test2::Util qw/try get_tid pkg_to_file/;
+use Test2::Util qw/try get_tid pkg_to_file IS_WIN32/;
use Test2::API qw/test2_ipc_set_pending/;
sub use_shm { 1 }
my $self = shift;
my ($hid) = @_;
my $tdir = $self->{+TEMPDIR};
- return File::Spec->canonpath("$tdir/HUB-$hid");
+ return File::Spec->catfile($tdir, "HUB-$hid");
}
sub event_file {
my @type = split '::', $type;
my $name = join('-', $hid, $$, get_tid(), $self->{+EVENT_ID}++, @type);
- return File::Spec->canonpath("$tempdir/$name");
+ return File::Spec->catfile($tempdir, $name);
}
sub add_hub {
$self->{+GLOBALS}->{$hid}->{$name}++;
}
+ my ($old, $blocked);
+ unless(IS_WIN32) {
+ my $to_block = POSIX::SigSet->new(
+ POSIX::SIGINT(),
+ POSIX::SIGALRM(),
+ POSIX::SIGHUP(),
+ POSIX::SIGTERM(),
+ POSIX::SIGUSR1(),
+ POSIX::SIGUSR2(),
+ );
+ $old = POSIX::SigSet->new;
+ $blocked = POSIX::sigprocmask(POSIX::SIG_BLOCK(), $to_block, $old);
+ # Silently go on if we failed to log signals, not much we can do.
+ }
+
+ # Write and rename the file.
my ($ok, $err) = try {
Storable::store($e, $file);
rename($file, $ready) or $self->abort("Could not rename file '$file' -> '$ready'");
test2_ipc_set_pending(substr($file, -(shm_size)));
};
+
+ # If our block was successful we want to restore the old mask.
+ POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old, POSIX::SigSet->new()) if defined $blocked;
+
if (!$ok) {
my $src_file = __FILE__;
$err =~ s{ at \Q$src_file\E.*$}{};
next if $global && $self->{+GLOBALS}->{$hid}->{$file}++;
# Untaint the path.
- my $full = File::Spec->canonpath("$tempdir/$file");
+ my $full = File::Spec->catfile($tempdir, $file);
($full) = ($full =~ m/^(.*)$/gs);
my $obj = $self->read_event_file($full);
while(my $file = readdir($dh)) {
next if $file =~ m/^\.+$/;
next if $file =~ m/\.complete$/;
- my $full = File::Spec->canonpath("$tempdir/$file");
+ my $full = File::Spec->catfile($tempdir, $file);
if ($file =~ m/^(GLOBAL|HUB-)/) {
$full =~ m/^(.*)$/;