perl核心模块解析(一)POSIX

时间:2015-08-14 19:06:12   收藏:0   阅读:5320

perl核心模块解析(一)    POSIX


详细文档链接如下

源自:http://blog.csdn.net/jonathanxqs

转自:http://perldoc.perl.org/POSIX.html


  POSIX/?p?z?ks/, 是可移植操作系统接口(Portable Operating System Interface ),POSIX标准定义了操作系统应该为应用程序提供的接口标准,是IEEE为要在各种UNIX操作系统上运行的软件而定义的一系列API标准的总称,其正式称呼为IEEE 1003,而国际标准名称为ISO/IEC 9945。

POSIX标准意在期望获得源代码级别的软件可移植性。换句话说,为一个POSIX兼容的操作系统编写的程序,应该可以在任何其它的POSIX操作系统(即使是来自另一个厂商)上编译执行。
POSIX 并不局限于 UNIX。许多其它的操作系统,例如 DEC OpenVMS 支持 POSIX 标准,尤其是 IEEE Std. 1003.1-1990(1995 年修订)或 POSIX.1,POSIX.1 提供了源代码级别的 C 语言应用编程接口(API)给操作系统的服务程序,例如读写文件。POSIX.1 已经被国际标准化组织(International Standards Organization,ISO)所接受,被命名为 ISO/IEC 9945-1:1990 标准。


POSIX

NAME

POSIX - Perl interface to IEEE Std 1003.1


SYNOPSIS

  1. use POSIX ();
  2. use POSIX qw(setsid);
  3. use POSIX qw(:errno_h :fcntl_h);
  4. printf "EINTR is %d\n", EINTR;
  5. $sess_id = POSIX::setsid();
  6. $fd = POSIX::open($path, O_CREAT|O_EXCL|O_WRONLY, 0644);
  7. # note: that‘s a filedescriptor, *NOT* a filehandle

DESCRIPTION

The POSIX module permits you to access all (or nearly all) the standard POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish interfaces.

This document gives a condensed list of the features available in the POSIX module. Consult your operating system‘s manpages for general information on most features. Consult perlfunc for functions which are noted as being identical to Perl‘s builtin functions.

The first section describes POSIX functions from the 1003.1 specification. The second section describes some classes for signal objects, TTY objects, and other miscellaneous objects. The remaining sections list various constants and macros in an organization which roughly follows IEEE Std 1003.1b-1993.

CAVEATS

Everything is exported by default (with a handful of exceptions). This is an unfortunate backwards compatibility feature and its use is strongly discouraged. You should either prevent the exporting (by saying use POSIX (); , as usual) and then use fully qualified names (e.g. POSIX::SEEK_END ), or give an explicit import list. If you do neither and opt for the default (as in use POSIX; ), you will import hundreds and hundreds of symbols into your namespace.

A few functions are not implemented because they are C specific. If you attempt to call these, they will print a message telling you that they aren‘t implemented, and suggest using the Perl equivalent, should one exist. For example, trying to access the setjmp() call will elicit the message "setjmp() is C-specific: use eval {} instead ".

Furthermore, some evil vendors will claim 1003.1 compliance, but in fact are not so: they will not pass the PCTS (POSIX Compliance Test Suites). For example, one vendor may not define EDEADLK , or the semantics of the errno values set by open(2) might not be quite right. Perl does not attempt to verify POSIX compliance. That means you can currently successfully say "use POSIX", and then later in your program you find that your vendor has been lax and there‘s no usable ICANON macro after all. This could be construed to be a bug.


FUNCTIONS

CLASSES

POSIX::SigAction

POSIX::SigRt

POSIX::SigSet

POSIX::Termios

PATHNAME CONSTANTS

POSIX CONSTANTS

SYSTEM CONFIGURATION

ERRNO

FCNTL

FLOAT

FLOATING-POINT ENVIRONMENT

LIMITS

LOCALE

MATH

SIGNAL

STAT

STDLIB

STDIO

TIME

UNISTD

WAIT


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!