package POSIX;
-our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = ();
+our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD, %SIGRT) = ();
+
+our $VERSION = "1.09";
use AutoLoader;
use XSLoader ();
-our $VERSION = "1.05" ;
-
# Grandfather old foo_h form to new :foo_h form
my $loaded;
goto &$AUTOLOAD;
}
-sub POSIX::SigAction::new {
- bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
+package POSIX::SigAction;
+
+use AutoLoader 'AUTOLOAD';
+sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 0}, $_[0] }
+
+package POSIX::SigRt;
+
+use strict;
+
+use Tie::Hash;
+use base qw(Tie::StdHash);
+
+use vars qw($SIGACTION_FLAGS);
+
+$SIGACTION_FLAGS = 0;
+
+my ($SIGRTMIN, $SIGRTMAX, $sigrtn);
+
+sub _init {
+ $SIGRTMIN = &POSIX::SIGRTMIN;
+ $SIGRTMAX = &POSIX::SIGRTMAX;
+ $sigrtn = $SIGRTMAX - $SIGRTMIN;
+}
+
+sub _croak {
+ &_init unless defined $sigrtn;
+ die "POSIX::SigRt not available" unless defined $sigrtn && $sigrtn > 0;
}
+sub _getsig {
+ &_croak;
+ my $rtsig = $_[0];
+ # Allow (SIGRT)?MIN( + n)?, a common idiom when doing these things in C.
+ $rtsig = $SIGRTMIN + ($1 || 0)
+ if $rtsig =~ /^(?:(?:SIG)?RT)?MIN(\s*\+\s*(\d+))?$/;
+ return $rtsig;
+}
+
+sub _exist {
+ my $rtsig = _getsig($_[1]);
+ my $ok = $rtsig >= $SIGRTMIN && $rtsig <= $SIGRTMAX;
+ ($rtsig, $ok);
+}
+
+sub _check {
+ my ($rtsig, $ok) = &_exist;
+ die "No POSIX::SigRt signal $_[1] (valid range SIGRTMIN..SIGRTMAX, or $SIGRTMIN..$SIGRTMAX)"
+ unless $ok;
+ return $rtsig;
+}
+
+sub new {
+ my ($rtsig, $handler, $flags) = @_;
+ my $sigset = POSIX::SigSet->new($rtsig);
+ my $sigact = POSIX::SigAction->new($handler,
+ $sigset,
+ $flags);
+ POSIX::sigaction($rtsig, $sigact);
+}
+
+sub EXISTS { &_exist }
+sub FETCH { my $rtsig = &_check;
+ my $oa = POSIX::SigAction->new();
+ POSIX::sigaction($rtsig, undef, $oa);
+ return $oa->{HANDLER} }
+sub STORE { my $rtsig = &_check; new($rtsig, $_[2], $SIGACTION_FLAGS) }
+sub DELETE { delete $SIG{ &_check } }
+sub CLEAR { &_exist; delete @SIG{ &POSIX::SIGRTMIN .. &POSIX::SIGRTMAX } }
+sub SCALAR { &_croak; $sigrtn + 1 }
+
+tie %POSIX::SIGRT, 'POSIX::SigRt';
+
+package POSIX;
+
1;
__END__
redef "IO::Seekable::seek()";
}
+sub fsync {
+ redef "IO::Handle::sync()";
+}
+
sub ferror {
redef "IO::Handle::error()";
}
}
sub div {
- unimpl "div() is C-specific, stopped";
+ unimpl "div() is C-specific, use /, % and int instead";
}
sub exit {
}
sub ldiv {
- unimpl "ldiv() is C-specific, use / and int instead";
+ unimpl "ldiv() is C-specific, use /, % and int instead";
}
sub malloc {
}
sub chown {
- usage "chown(filename, uid, gid)" if @_ != 3;
+ usage "chown(uid, gid, filename)" if @_ != 3;
CORE::chown($_[0], $_[1], $_[2]);
}
signal_h => [qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK
SA_RESETHAND SA_RESTART SA_SIGINFO SIGABRT SIGALRM
SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL
- SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN
- SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR
- SIG_IGN SIG_SETMASK SIG_UNBLOCK raise sigaction signal
- sigpending sigprocmask sigsuspend)],
+ SIGPIPE %SIGRT SIGRTMIN SIGRTMAX SIGQUIT SIGSEGV SIGSTOP
+ SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2
+ SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK
+ raise sigaction signal sigpending sigprocmask sigsuspend)],
stdarg_h => [],
_SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
_exit access ctermid cuserid
dup2 dup execl execle execlp execv execve execvp
- fpathconf getcwd getegid geteuid getgid getgroups
+ fpathconf fsync getcwd getegid geteuid getgid getgroups
getpid getuid isatty lseek pathconf pause setgid setpgid
setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)],
gmtime
isatty
kill
+ lchown
link
localtime
log
require Exporter;
}
+
+package POSIX::SigAction;
+
+sub handler { $_[0]->{HANDLER} = $_[1] if @_ > 1; $_[0]->{HANDLER} };
+sub mask { $_[0]->{MASK} = $_[1] if @_ > 1; $_[0]->{MASK} };
+sub flags { $_[0]->{FLAGS} = $_[1] if @_ > 1; $_[0]->{FLAGS} };
+sub safe { $_[0]->{SAFE} = $_[1] if @_ > 1; $_[0]->{SAFE} };
+