use POSIX; use POSIX qw(setsid); use POSIX qw(:errno_h :fcntl_h); printf "EINTR is %d\n", EINTR; $sess_id = POSIX::setsid(); $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644); # note: $fd is a filedescriptor, *NOT* a file handle ***** $sigset = POSIX::SigSet->new; $sigaction = POSIX::SigAction->new('main::handler', $sigset, &POSIX::SA_NOCLDSTOP); ***** $sigset = POSIX::SigSet->new; ***** $sigset = POSIX::SigSet->new(&POSIX::SIGUSR1); ***** $sigset->addset(&POSIX::SIGUSR2); ***** $sigset->delset(&POSIX::SIGUSR2); ***** $sigset->emptyset(); ***** $sigset->fillset(); ***** if ($sigset->ismember(&POSIX::SIGUSR1 ) ){ print "contains SIGUSR1\n"; } ***** $termios = POSIX::Termios->new; ***** $termios->getattr() ***** $termios->getattr(1) ***** $c_cc[1] = $termios->getcc(1); ***** $c_cflag = $termios->getcflag; ***** $c_iflag = $termios->getiflag; ***** $ispeed = $termios->getispeed; ***** $c_lflag = $termios->getlflag; ***** $c_oflag = $termios->getoflag; ***** $ospeed = $termios->getospeed; ***** $termios->setattr(1, &POSIX::TCSANOW); ***** $termios->setcc(1, &POSIX::VEOF); ***** $termios->setcflag(&POSIX::CLOCAL); ***** $termios->setiflag(&POSIX::BRKINT); ***** $termios->setispeed(&POSIX::B9600); ***** $termios->setlflag(&POSIX::ECHO); ***** $termios->setoflag(&POSIX::OPOST); ***** $termios->setospeed(&POSIX::B9600); ***** #!/usr/bin/perl -w use strict; $| = 1; for (1..4) { my $got; print "gimme: "; $got = getone(); print "--> $got\n"; } exit; BEGIN { use POSIX qw(:termios_h); my ($term, $oterm, $echo, $noecho, $fd_stdin); $fd_stdin = fileno(STDIN); $term = POSIX::Termios->new(); $term->getattr($fd_stdin); $oterm = $term->getlflag(); $echo = ECHO | ECHOK | ICANON; $noecho = $oterm & ~$echo; sub cbreak { $term->setlflag($noecho); $term->setcc(VTIME, 1); $term->setattr($fd_stdin, TCSANOW); } sub cooked { $term->setlflag($oterm); $term->setcc(VTIME, 0); $term->setattr($fd_stdin, TCSANOW); } sub getone { my $key = ''; cbreak(); sysread(STDIN, $key, 1); cooked(); return $key; } } END { cooked() } ***** if (POSIX::access("/", &POSIX::R_OK ) ){ print "have read permission\n"; } ***** $fd = POSIX::open("foo", &POSIX::O_RDONLY); POSIX::close($fd); ***** $fd = POSIX::creat("foo", 0611); POSIX::close($fd); ***** $path = POSIX::ctermid(); ***** $name = POSIX::cuserid(); ***** $errno = POSIX::errno(); ***** $fd = POSIX::open("/tmp/foo", &POSIX::O_RDONLY); $path_max = POSIX::fpathconf($fd, &POSIX::_PC_PATH_MAX); ***** ($mantissa, $exponent) = POSIX::frexp(3.14); ***** $fd = POSIX::open("foo", &POSIX::O_RDONLY); @stats = POSIX::fstat($fd); ***** $loc = POSIX::setlocale(&POSIX::LC_ALL, "de"); print "Locale = $loc\n"; $lconv = POSIX::localeconv(); print "decimal_point = ", $lconv->{decimal_point}, "\n"; print "thousands_sep = ", $lconv->{thousands_sep}, "\n"; print "grouping = ", $lconv->{grouping}, "\n"; print "int_curr_symbol = ", $lconv->{int_curr_symbol}, "\n"; print "currency_symbol = ", $lconv->{currency_symbol}, "\n"; print "mon_decimal_point = ",$lconv->{mon_decimal_point}, "\n"; print "mon_thousands_sep = ",$lconv->{mon_thousands_sep}, "\n"; print "mon_grouping = ", $lconv->{mon_grouping}, "\n"; print "positive_sign = ", $lconv->{positive_sign}, "\n"; print "negative_sign = ", $lconv->{negative_sign}, "\n"; print "int_frac_digits = ", $lconv->{int_frac_digits}, "\n"; print "frac_digits = ", $lconv->{frac_digits}, "\n"; print "p_cs_precedes = ", $lconv->{p_cs_precedes}, "\n"; print "p_sep_by_space = ", $lconv->{p_sep_by_space}, "\n"; print "n_cs_precedes = ", $lconv->{n_cs_precedes}, "\n"; print "n_sep_by_space = ", $lconv->{n_sep_by_space}, "\n"; print "p_sign_posn = ", $lconv->{p_sign_posn}, "\n"; print "n_sign_posn = ", $lconv->{n_sign_posn}, "\n"; ***** $fd = POSIX::open("foo", &POSIX::O_RDONLY); $off_t = POSIX::lseek($fd, 0, &POSIX::SEEK_SET); ***** mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0) ***** $time_t = POSIX::mktime(0, 30, 10, 12, 11, 95); print "Date = ", POSIX::ctime($time_t); ***** ($fractional, $integral) = POSIX::modf(3.14); ***** $fd = POSIX::open("foo"); ***** $fd = POSIX::open("foo", &POSIX::O_RDWR); ***** $fd = POSIX::open("foo", &POSIX::O_WRONLY | &POSIX::O_TRUNC); ***** $fd = POSIX::open("foo", &POSIX::O_CREAT | &POSIX::O_WRONLY, 0644); ***** $dir = POSIX::opendir("/tmp"); @files = POSIX::readdir($dir); POSIX::closedir($dir); ***** $path_max = POSIX::pathconf("/tmp", &POSIX::_PC_PATH_MAX); ***** ($fd0, $fd1) = POSIX::pipe(); POSIX::write($fd0, "hello", 5); POSIX::read($fd1, $buf, 5); ***** $ret = POSIX::pow($x, $exponent); ***** $fd = POSIX::open("foo", &POSIX::O_RDONLY); $bytes = POSIX::read($fd, $buf, 3); ***** $loc = POSIX::setlocale(&POSIX::LC_ALL, "C"); ***** sigaction(sig, action, oldaction = 0) ***** sigpending(sigset) ***** sigprocmask(how, sigset, oldsigset = 0) ***** sigsuspend(signal_mask) ***** strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0) ***** $str = POSIX::strftime("%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2); print "$str\n"; ***** $dst = POSIX::strxfrm($src); ***** $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK); ***** ($realtime, $user, $system, $cuser, $csystem) = POSIX::times(); ***** $tmpfile = POSIX::tmpnam(); ***** POSIX::tzset(); ($std, $dst) = POSIX::tzname(); ***** ($sysname, $nodename, $release, $version, $machine ) = POSIX::uname(); ***** $pid = POSIX::waitpid(-1, &POSIX::WNOHANG); print "status = ", ($? / 256), "\n"; ***** $fd = POSIX::open("foo", &POSIX::O_WRONLY); $buf = "hello"; $bytes = POSIX::write($b, $buf, 5);