Return $? back safely

This commit is contained in:
Ryan Voots 2017-05-21 09:40:02 -07:00
parent 03318dc6e8
commit 8ce0412a8f
2 changed files with 3 additions and 6 deletions

View file

@ -124,12 +124,10 @@ sub run {
croak "Run must be given a codref to run" unless ref $code eq "CODE";
$self->pre_setup(%args);
$self->_subprocess(sub {
return $self->_subprocess(sub {
$self->post_setup(%args);
$code->(%args);
}, %args);
return 1;
}
1;

View file

@ -5,11 +5,9 @@ BEGIN {
use Test::More;
use Test::SharedFork;
# test 1
use Sys::Linux::Namespace;
$Sys::Linux::Namespace::debug = 1;
# test 2
SKIP: {
skip "Need to be root to run test", 5 unless $< == 0;
ok(my $namespace = Sys::Linux::Namespace->new(private_tmp => 1), "Setup object");
@ -25,7 +23,8 @@ SKIP: {
is_deeply([grep {m|/proc/\d+/|} glob '/proc/*/'], ['/proc/1/'], "Only /proc/1/ exists");
});
ok($ret, "run code in sandbox");
# namespace process exited cleanly
ok($ret == 0, "run code in sandbox");
alarm(5);
$pid_ns->run(code => sub {