POSIX是什么?我读过维基百科上的文章,每次遇到这个词我都会去读。事实上,我从来没有真正理解它是什么。
有没有人可以通过解释“POSIX的需求”来解释给我听?
POSIX是什么?我读过维基百科上的文章,每次遇到这个词我都会去读。事实上,我从来没有真正理解它是什么。
有没有人可以通过解释“POSIX的需求”来解释给我听?
当前回答
In 1985, individuals from companies throughout the computer industry joined together to develop the POSIX (Portable Operating System Interface for Computer Environments) standard, which is based largely on the UNIX System V Interface Definition (SVID) and other earlier standardization efforts. These efforts were spurred by the U.S. government, which needed a standard computing environment to minimize its training and procurement costs. Released in 1988, POSIX is a group of IEEE standards that define the API, shell, and utility interfaces for an operating system. Although aimed at UNIX-like systems, the standards can apply to any compatible operating system. Now that these stan- dards have gained acceptance, software developers are able to develop applications that run on all conforming versions of UNIX, Linux, and other operating systems.
摘自《Linux实用指南》
其他回答
关于POSIX的一些事实并不那么明朗。
POSIX也是系统调用接口或API,它有将近30年的历史。
它被设计用于对本地存储的串行数据访问,使用具有单个cpu的单台计算机。
在POSIX的设计中,安全性并不是一个主要的问题,这导致了多年来大量的竞争条件攻击,迫使程序员绕过这些限制。
严重的错误仍在被发现,这些错误本可以通过更安全的POSIX API设计来避免。
POSIX期望用户一次发出一个同步调用,并在发出下一个调用之前等待它的结果。今天的程序员希望一次发出许多异步请求,以提高总体吞吐量。
这种同步API对于访问远程和云对象尤其不利,因为在这些地方,高延迟很重要。
POSIX是IEEE和开放组织提出的一组标准,描述了理想的Unix如何运行。程序员、用户和管理员都可以熟悉POSIX文档,并期望POSIX投诉Unix提供所有提到的标准功能。
由于每个Unix的工作方式都略有不同——Solaris、Mac OS X、IRIX、BSD和Linux都有自己的怪癖——POSIX对业内人士特别有用,因为它定义了一个标准的操作环境。例如,C库中的大多数函数都基于POSIX;因此,程序员可以在他的应用程序中使用一个,并期望它在大多数unix中表现相同。
然而,Unix的不同领域通常是重点,而不是标准领域。
POSIX的伟大之处在于,欢迎您自己阅读:
开放组基础规范第7期
第7版被称为POSIX.1-2008,其中有新的东西——但是,POSIX.1的Google-fu等将允许您看到Unix背后的整个历史。
In 1985, individuals from companies throughout the computer industry joined together to develop the POSIX (Portable Operating System Interface for Computer Environments) standard, which is based largely on the UNIX System V Interface Definition (SVID) and other earlier standardization efforts. These efforts were spurred by the U.S. government, which needed a standard computing environment to minimize its training and procurement costs. Released in 1988, POSIX is a group of IEEE standards that define the API, shell, and utility interfaces for an operating system. Although aimed at UNIX-like systems, the standards can apply to any compatible operating system. Now that these stan- dards have gained acceptance, software developers are able to develop applications that run on all conforming versions of UNIX, Linux, and other operating systems.
摘自《Linux实用指南》
POSIX是IEEE指定的一系列标准,用于阐明和统一Unix-y操作系统提供的应用程序编程接口(以及辅助问题,如命令行shell实用程序)。
当您编写依赖POSIX标准的程序时,您可以相当肯定地将它们轻松地移植到大量的Unix衍生产品中(包括Linux,但不限于它!);如果你使用的某些Linux API不是Posix的一部分,那么将来你想要将该程序或库移植到其他unix系统(例如MacOSX)时,你将会遇到困难。
POSIX 7定义的最重要的东西
C API Greatly extends ANSI C with things like: more file operations: mkdir, dirname, symlink, readlink, link (hardlinks), poll(), stat, sync, nftw() process and threads: fork, execl, wait, pipe, semaphors sem_*, shared memory (shm_*), kill, scheduling parameters (nice, sched_*), sleep, mkfifo, setpgid() networking: socket() memory management: mmap, mlock, mprotect, madvise, brk() utilities: regular expressions (reg*) Those APIs also determine underlying system concepts on which they depend, e.g. fork requires a concept of a process. Many Linux system calls exist to implement a specific POSIX C API function and make Linux compliant, e.g. sys_write, sys_read, ... Many of those syscalls also have Linux-specific extensions however. Major Linux desktop implementation: glibc, which in many cases just provides a shallow wrapper to system calls. CLI utilities E.g.: cd, ls, echo, ... Many utilities are direct shell front ends for a corresponding C API function, e.g. mkdir. Major Linux desktop implementation: GNU Coreutils for the small ones, separate GNU projects for the big ones: sed, grep, awk, ... Some CLI utilities are implemented by Bash as built-ins. Shell language E.g., a=b; echo "$a" Major Linux desktop implementation: GNU Bash. Environment variables E.g.: HOME, PATH. PATH search semantics are specified, including how slashes prevent PATH search. Program exit status ANSI C says 0 or EXIT_SUCCESS for success, EXIT_FAILURE for failure, and leaves the rest implementation defined. POSIX adds: 126: command found but not executable. 127: command not found. > 128: terminated by a signal. But POSIX does not seem to specify the 128 + SIGNAL_ID rule used by Bash: https://unix.stackexchange.com/questions/99112/default-exit-code-when-process-is-terminated See also: What is the meaning of $? (dollar question mark) in shell scripts? Regular expression There are two types: BRE (Basic) and ERE (Extended). Basic is deprecated and only kept to not break APIs. Those are implemented by C API functions, and used throughout CLI utilities, e.g. grep accepts BREs by default, and EREs with -E. E.g.: echo 'a.1' | grep -E 'a.[[:digit:]]' Major Linux implementation: glibc implements the functions under regex.h which programs like grep can use as backend. Directory structure E.g.: /dev/null, /tmp The Linux FHS greatly extends POSIX. Filenames / is the path separator NUL cannot be used . is cwd, .. parent portable filenames use at most max 14 chars and 256 for the full path can only contain: a-zA-Z0-9._- See also: what is posix compliance for filesystem? Command line utility API conventions Not mandatory, used by POSIX, but almost nowhere else, notably not in GNU. But true, it is too restrictive, e.g. single letter flags only (e.g. -a), no double hyphen long versions (e.g. --all). A few widely used conventions: - means stdin where a file is expected -- terminates flags, e.g. ls -- -l to list a directory named -l See also: Are there standards for Linux command line switches and arguments? "POSIX ACLs" (Access Control Lists), e.g. as used as backend for setfacl. This was withdrawn but it was implemented in several OSes, including in Linux with setxattr.
谁符合POSIX?
许多系统密切遵循POSIX,但很少有系统实际上得到维护该标准的开放组织的认证。值得注意的认证包括:
OS X (Apple) X同时代表10和UNIX。是第一个苹果POSIX系统,发布于2001年左右。请参见:OSX是POSIX操作系统吗? AIX (IBM) HP - ux (HP) Solaris (Oracle)
大多数Linux发行版都是非常合规的,但没有认证,因为他们不想支付合规检查。浪潮的K-UX和华为的EulerOS就是两个经过认证的例子。
认证系统的官方列表可以在https://www.opengroup.org/openbrand/register/和wiki页面上找到。
窗户
Windows在它的一些专业发行版上实现了POSIX。
因为它是一个可选的特性,所以程序员不能在大多数终端用户应用程序中依赖它。
Windows 8已弃用支持:
微软Windows 7 POSIX实现目前处于什么位置? https://superuser.com/questions/495360/does-windows-8-still-implement-posix 专题请求:https://windows.uservoice.com/forums/265757-windows-feature-suggestions/suggestions/6573649-full-posix-support
2016年,一个名为“Windows子系统for Linux”的新的官方类Linux API发布。它包括Linux系统调用,ELF运行,部分/proc文件系统,Bash, GCC, (TODO可能是glibc?), apt-get和更多:https://channel9.msdn.com/Events/Build/2016/P488所以我相信它将允许Windows运行大部分POSIX,如果不是全部的话。但是,它关注的是开发人员/部署,而不是最终用户。特别是,没有允许访问Windows GUI的计划。
官方Microsoft POSIX兼容性的历史概述:http://brianreiter.org/2010/08/24/the-sad-history-of-the-microsoft-posix-subsystem/
Cygwin是一个著名的GPL第三方项目,因为它为Windows“提供了大量的POSIX API功能”,但如果你想让应用程序在Windows上运行,就需要你“从源代码重新构建应用程序”。MSYS2是一个相关的项目,它似乎在Cygwin的基础上添加了更多的功能。
If the only thing from POSIX that you need are the command line utilities, also consider: https://github.com/shelljs/shelljs which re-implements a bunch of CLI utilities in Node.js, which already essentially implements a portability layer for the simpler system calls like mkdir etc. Many people use that project in the package.json of their project to allow running the project on Windows as well. Of course, it requires users to install the Node.js runtime, but given the popularity of Node.js, I don't expect that to break/be hard to satisfy anytime soon.
安卓
Android有自己的C库(Bionic),不完全支持POSIX作为Android O: Android POSIX兼容吗?
奖金水平
Linux标准库进一步扩展了POSIX。
使用非框架索引,它们更易于阅读和搜索:http://pubs.opengroup.org/onlinepubs/9699919799/nfindex.html
获取grepping的HTML页面的完整压缩版本:POSIX C API函数的列表在哪里?