Add clone syscall.

This commit is contained in:
Ryan Voots 2017-05-07 13:22:13 -07:00
parent 874bf2fbd6
commit 865dc0b66d
2 changed files with 16 additions and 1 deletions

View file

@ -20,10 +20,21 @@ our %EXPORT_TAGS = (
'all' => [@unshare_consts, qw/unshare/],
);
sub clone {
my ($flags) = @_;
local $! = 0;
my $ret_pid = _clone_sys($flags);
if ($ret_pid < 0) {
croak "Clone call failed: $ret_pid $!";
}
return $ret_pid;
}
sub unshare {
my ($flags) = @_;
local $! = 0;
my $ret = _unshare_sys($flags);

View file

@ -20,3 +20,7 @@ SV * _unshare_sys(int flags)
ST(0) = sv_newmortal();
sv_setiv(ST(0), unshare(flags));
SV * _clone_sys(int flags)
CODE:
ST(0) = sv_newmortal();
sv_setiv(ST(0), clone(NULL, NULL, CLONE_CHILD_CLEARTID|SIGCHLD|flags, NULL));