Skip to content

Commit

Permalink
- Added the Sys.wait and Sys.fork methods
Browse files Browse the repository at this point in the history
- Added the Socket.socketpair method (see: perldoc -f socketpair)
  • Loading branch information
trizen committed Sep 16, 2015
1 parent 41f9013 commit 6617f38
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/Sidef/Sys/Sys.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ package Sidef::Sys::Sys {
exit($code // 0);
}

sub wait {
my ($self) = @_;
Sidef::Types::Number::Number->new(CORE::wait);
}

sub fork {
my ($self) = @_;
Sidef::Types::Number::Number->new(fork() // return);
}

sub alarm {
my ($self, $sec) = @_;

Expand Down
6 changes: 3 additions & 3 deletions lib/Sidef/Types/Glob/FileHandle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ package Sidef::Types::Glob::FileHandle {
CORE::binmode($self->{fh}, $encoding->get_value);
}

sub write_string {
sub syswrite {
my ($self, @args) = @_;
Sidef::Types::Bool::Bool->new(syswrite $self->{fh}, @args);
Sidef::Types::Bool::Bool->new(CORE::syswrite $self->{fh}, @args);
}

*syswrite = \&write_string;
*write_string = \&syswrite;

sub print {
my ($self, @args) = @_;
Expand Down
9 changes: 9 additions & 0 deletions lib/Sidef/Types/Glob/Socket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ package Sidef::Types::Glob::Socket {
Sidef::Types::Glob::SocketHandle->new(fh => $fh);
}

sub socketpair {
my ($self, $socket1, $socket2, $domain, $type, $protocol) = @_;
CORE::socketpair(my $sh1, my $sh2, $domain->get_value, $type->get_value, $protocol->get_value)
|| return Sidef::Types::Bool::Bool->false;
$socket1->get_var->set_value(Sidef::Types::Glob::SocketHandle->new(fh => $sh1));
$socket2->get_var->set_value(Sidef::Types::Glob::SocketHandle->new(fh => $sh2));
Sidef::Types::Bool::Bool->true;
}

#
## gethost*
#
Expand Down

0 comments on commit 6617f38

Please sign in to comment.