📄 posix.pod
字号:
=item setsidThis is identical to the C function C<setsid()> forsetting the session identifier of the current process.=item setuidSets the real user identifier and the effective user identifier forthis process. Similar to assigning a value to the Perl's builtinC<$E<lt>> variable, see L<perlvar/$UID>, except that the latterwill change only the real user identifier.=item sigactionDetailed signal management. This uses C<POSIX::SigAction> objects forthe C<action> and C<oldaction> arguments (the oldaction can also bejust a hash reference). Consult your system's C<sigaction> manpagefor details, see also C<POSIX::SigRt>.Synopsis: sigaction(signal, action, oldaction = 0)Returns C<undef> on failure. The C<signal> must be a number (likeSIGHUP), not a string (like "SIGHUP"), though Perl does try hardto understand you.If you use the SA_SIGINFO flag, the signal handler will in addition tothe first argument, the signal name, also receive a second argument, ahash reference, inside which are the following keys with the followingsemantics, as defined by POSIX/SUSv3: signo the signal number errno the error number code if this is zero or less, the signal was sent by a user process and the uid and pid make sense, otherwise the signal was sent by the kernelThe following are also defined by POSIX/SUSv3, but unfortunatelynot very widely implemented: pid the process id generating the signal uid the uid of the process id generating the signal status exit value or signal for SIGCHLD band band event for SIGPOLLA third argument is also passed to the handler, which contains a copyof the raw binary contents of the siginfo structure: if a system hassome non-POSIX fields, this third argument is where to unpack() themfrom.Note that not all siginfo values make sense simultaneously (some arevalid only for certain signals, for example), and not all values makesense from Perl perspective, you should to consult your system'sC<sigaction> and possibly also C<siginfo> documentation.=item siglongjmpsiglongjmp() is C-specific: use L<perlfunc/die> instead.=item sigpendingExamine signals that are blocked and pending. This uses C<POSIX::SigSet>objects for the C<sigset> argument. Consult your system's C<sigpending>manpage for details.Synopsis: sigpending(sigset)Returns C<undef> on failure.=item sigprocmaskChange and/or examine calling process's signal mask. This usesC<POSIX::SigSet> objects for the C<sigset> and C<oldsigset> arguments.Consult your system's C<sigprocmask> manpage for details.Synopsis: sigprocmask(how, sigset, oldsigset = 0)Returns C<undef> on failure.=item sigsetjmpC<sigsetjmp()> is C-specific: use C<eval {}> instead,see L<perlfunc/eval>.=item sigsuspendInstall a signal mask and suspend process until signal arrives. This usesC<POSIX::SigSet> objects for the C<signal_mask> argument. Consult yoursystem's C<sigsuspend> manpage for details.Synopsis: sigsuspend(signal_mask)Returns C<undef> on failure.=item sinThis is identical to Perl's builtin C<sin()> functionfor returning the sine of the numerical argument,see L<perlfunc/sin>. See also L<Math::Trig>.=item sinhThis is identical to the C function C<sinh()>for returning the hyperbolic sine of the numerical argument.See also L<Math::Trig>.=item sleepThis is functionally identical to Perl's builtin C<sleep()> functionfor suspending the execution of the current for process for certainnumber of seconds, see L<perlfunc/sleep>. There is one significantdifference, however: C<POSIX::sleep()> returns the number ofB<unslept> seconds, while the C<CORE::sleep()> returns thenumber of slept seconds.=item sprintfThis is similar to Perl's builtin C<sprintf()> functionfor returning a string that has the arguments formatted as requested,see L<perlfunc/sprintf>.=item sqrtThis is identical to Perl's builtin C<sqrt()> function.for returning the square root of the numerical argument,see L<perlfunc/sqrt>.=item srandGive a seed the pseudorandom number generator, see L<perlfunc/srand>.=item sscanfsscanf() is C-specific, use regular expressions instead,see L<perlre>.=item statThis is identical to Perl's builtin C<stat()> functionfor returning information about files and directories.=item strcatstrcat() is C-specific, use C<.=> instead, see L<perlop>.=item strchrstrchr() is C-specific, see L<perlfunc/index> instead.=item strcmpstrcmp() is C-specific, use C<eq> or C<cmp> instead, see L<perlop>.=item strcollThis is identical to the C function C<strcoll()>for collating (comparing) strings transformed usingthe C<strxfrm()> function. Not really needed sincePerl can do this transparently, see L<perllocale>.=item strcpystrcpy() is C-specific, use C<=> instead, see L<perlop>.=item strcspnstrcspn() is C-specific, use regular expressions instead,see L<perlre>.=item strerrorReturns the error string for the specified errno.Identical to the string form of the C<$!>, see L<perlvar/$ERRNO>.=item strftimeConvert date and time information to string. Returns the string.Synopsis: strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)The month (C<mon>), weekday (C<wday>), and yearday (C<yday>) begin at zero.I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. Theyear (C<year>) is given in years since 1900. I.e., the year 1995 is 95; theyear 2001 is 101. Consult your system's C<strftime()> manpage for detailsabout these and the other arguments.If you want your code to be portable, your format (C<fmt>) argumentshould use only the conversion specifiers defined by the ANSI Cstandard (C89, to play safe). These are C<aAbBcdHIjmMpSUwWxXyYZ%>.But even then, the B<results> of some of the conversion specifiers arenon-portable. For example, the specifiers C<aAbBcpZ> change accordingto the locale settings of the user, and both how to set locales (thelocale names) and what output to expect are non-standard.The specifier C<c> changes according to the timezone settings of theuser and the timezone computation rules of the operating system.The C<Z> specifier is notoriously unportable since the names oftimezones are non-standard. Sticking to the numeric specifiers is thesafest route.The given arguments are made consistent as though by callingC<mktime()> before calling your system's C<strftime()> function,except that the C<isdst> value is not affected.The string for Tuesday, December 12, 1995. $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 ); print "$str\n";=item strlenstrlen() is C-specific, use C<length()> instead, see L<perlfunc/length>.=item strncatstrncat() is C-specific, use C<.=> instead, see L<perlop>.=item strncmpstrncmp() is C-specific, use C<eq> instead, see L<perlop>.=item strncpystrncpy() is C-specific, use C<=> instead, see L<perlop>.=item strpbrkstrpbrk() is C-specific, use regular expressions instead,see L<perlre>.=item strrchrstrrchr() is C-specific, see L<perlfunc/rindex> instead.=item strspnstrspn() is C-specific, use regular expressions instead,see L<perlre>.=item strstrThis is identical to Perl's builtin C<index()> function,see L<perlfunc/index>.=item strtodString to double translation. Returns the parsed number and the numberof characters in the unparsed portion of the string. TrulyPOSIX-compliant systems set $! ($ERRNO) to indicate a translationerror, so clear $! before calling strtod. However, non-POSIX systemsmay not check for overflow, and therefore will never set $!.strtod should respect any POSIX I<setlocale()> settings.To parse a string $str as a floating point number use $! = 0; ($num, $n_unparsed) = POSIX::strtod($str);The second returned item and $! can be used to check for valid input: if (($str eq '') || ($n_unparsed != 0) || $!) { die "Non-numeric input $str" . ($! ? ": $!\n" : "\n"); }When called in a scalar context strtod returns the parsed number.=item strtokstrtok() is C-specific, use regular expressions instead, seeL<perlre>, or L<perlfunc/split>.=item strtolString to (long) integer translation. Returns the parsed number andthe number of characters in the unparsed portion of the string. TrulyPOSIX-compliant systems set $! ($ERRNO) to indicate a translationerror, so clear $! before calling strtol. However, non-POSIX systemsmay not check for overflow, and therefore will never set $!.strtol should respect any POSIX I<setlocale()> settings.To parse a string $str as a number in some base $base use $! = 0; ($num, $n_unparsed) = POSIX::strtol($str, $base);The base should be zero or between 2 and 36, inclusive. When the baseis zero or omitted strtol will use the string itself to determine thebase: a leading "0x" or "0X" means hexadecimal; a leading "0" meansoctal; any other leading characters mean decimal. Thus, "1234" isparsed as a decimal number, "01234" as an octal number, and "0x1234"as a hexadecimal number.The second returned item and $! can be used to check for valid input: if (($str eq '') || ($n_unparsed != 0) || !$!) { die "Non-numeric input $str" . $! ? ": $!\n" : "\n"; }When called in a scalar context strtol returns the parsed number.=item strtoulString to unsigned (long) integer translation. strtoul() is identicalto strtol() except that strtoul() only parses unsigned integers. SeeL</strtol> for details.Note: Some vendors supply strtod() and strtol() but not strtoul().Other vendors that do supply strtoul() parse "-1" as a valid value.=item strxfrmString transformation. Returns the transformed string. $dst = POSIX::strxfrm( $src );Used in conjunction with the C<strcoll()> function, see L</strcoll>.Not really needed since Perl can do this transparently, seeL<perllocale>.=item sysconfRetrieves values of system configurable variables.The following will get the machine's clock speed. $clock_ticks = POSIX::sysconf( &POSIX::_SC_CLK_TCK );Returns C<undef> on failure.=item systemThis is identical to Perl's builtin C<system()> function, seeL<perlfunc/system>.=item tanThis is identical to the C function C<tan()>, returning thetangent of the numerical argument. See also L<Math::Trig>.=item tanhThis is identical to the C function C<tanh()>, returning thehyperbolic tangent of the numerical argument. See also L<Math::Trig>.=item tcdrainThis is similar to the C function C<tcdrain()> for drainingthe output queue of its argument stream.Returns C<undef> on failure.=item tcflowThis is similar to the C function C<tcflow()> for controllingthe flow of its argument stream.Returns C<undef> on failure.=item tcflushThis is similar to the C function C<tcflush()> for flushingthe I/O buffers of its argument stream.Returns C<undef> on failure.=item tcgetpgrpThis is identical to the C function C<tcgetpgrp()> for returning theprocess group identifier of the foreground process group of the controllingterminal.=item tcsendbreakThis is similar to the C function C<tcsendbreak()> for sendinga break on its argument stream.Returns C<undef> on failure.=item tcsetpgrpThis is similar to the C function C<tcsetpgrp()> for setting theprocess group identifier of the foreground process group of the controllingterminal.Returns C<undef> on failure.=item timeThis is identical to Perl's builtin C<time()> functionfor returning the number of seconds since the epoch(whatever it is for the system), see L<perlfunc/time>.=item timesThe times() function returns elapsed realtime since some point in the past(such as system startup), user and system times for this process, and userand system times used by child processes. All times are returned in clockticks. ($realtime, $user, $system, $cuser, $csystem) = POSIX::times();Note: Perl's builtin C<times()> function returns four values, measured inseconds.=item tmpfileUse method C<IO::File::new_tmpfile()> instead, or see L<File::Temp>.=item tmpnamReturns a name for a temporary file. $tmpfile = POSIX::tmpnam();For security reasons, which are probably detailed in your system'sdocumentation for the C library tmpnam() function, this interfaceshould not be used; instead see L<File::Temp>.=item tolowerThis is identical to the C function, except that it can apply to a singlecharacter or to a whole string. Consider using the C<lc()> function,see L<perlfunc/lc>, or the equivalent C<\L> operator inside doublequotishstrings.=item toupperThis is identical to the C function, except that it can apply to a singlecharacter or to a whole string. Consider using the C<uc()> function,see L<perlfunc/uc>, or the equivalent C<\U> operator inside doublequotishstrings.=item ttynameThis is identical to the C function C<ttyname()> for returning thename of the current terminal.=item tznameRetrieves the time conversion information from the C<tzname> variable. POSIX::tzset(); ($std, $dst) = POSIX::tzname();=item tzsetThis is identical to the C function C<tzset()> for settingthe current timezone based on the environment variable C<TZ>,to be used by C<ctime()>, C<localtime()>, C<mktime()>, and C<strftime()>functions.=item umaskThis is identical to Perl's builtin C<umask()> functionfor setting (and querying) the file creation permission mask,see L<perlfunc/umask>.=item unameGet name of current operating system. ($sysname, $nodename, $release, $version, $machine) = POSIX::uname();Note that the actual meanings of the various fields are notthat well standardized, do not expect any great portability.The C<$sysname> might be the name of the operating system,the C<$nodename> might be the name of the host, the C<$release>might be the (major) release number of the operating system,the C<$version> might be the (minor) release number of theoperating system, and the C<$machine> might be a hardware identifier.Maybe.=item ungetcUse method C<IO::Handle::ungetc()> instead.=item unlinkThis is identical to Perl's builtin C<unlink()> functionfor removing files, see L<perlfunc/unlink>.=item utimeThis is identical to Perl's builtin C<utime()> functionfor changing the time stamps of files and directories,see L<perlfunc/utime>.=item vfprintfvfprintf() is C-specific, see L<perlfunc/printf> instead.=item vprintfvprintf() is C-specific, see L<perlfunc/printf> instead.=item vsprintfvsprintf() is C-specific, see L<perlfunc/sprintf> instead.=item waitThis is identical to Perl's builtin C<wait()> function,see L<perlfunc/wait>.=item waitpidWait for a child process to change state. This is identical to Perl'sbuiltin C<waitpid()> function, see L<perlfunc/waitpid>. $pid = POSIX::waitpid( -1, POSIX::WNOHANG ); print "status = ", ($? / 256), "\n";=item wcstombsThis is identical to the C function C<wcstombs()>.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function.=item wctombThis is identical to the C function C<wctomb()>.Perl does not have any support for the wide and multibytecharacters of the C standards, so this might be a ratheruseless function.=item writeWrite to a file. This uses file descriptors such as those obtained bycalling C<POSIX::open>. $fd = POSIX::open( "foo", &POSIX::O_WRONLY ); $buf = "hello"; $bytes = POSIX::write( $b, $buf, 5 );Returns C<undef> on failure.See also L<perlfunc/syswrite>.=back=head1 CLASSES
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -