api – What is POSIX?

Question:

I know the acronym Portable Operating System Interface (POSIX), but what is it? Does it have to do with UNIX? Windows cannot be POSIX?

What does it matter to the developer?

Answer:

What is it?

POSIX, as the name suggests, is a standard for determining common interfaces between operating systems.

POSIX is nothing more than a way of dictating various expected characteristics of an operating system. Normally, when we write and compile programs in C and C++, it is common to take some system behaviors as true.

For example, when we are using a command interpreter that is POSIX compliant, it is expected that we will be able to invoke the ls command.

Where did it come from?

In the 70s and 80s, several operating system initiatives began to emerge, and as each company/developer made its own interfaces, it was realized that standardization was necessary.

In an attempt to make programs more compatible across various operating systems, POSIX was written. It basically defines system calls, basic commands (like awk and echo), a shell script compatible command interpreter, various expected system behaviors (like signals, pipes, basic process management, etc).

Note : It is important to remember that Richard Stallman is one of the authors of POSIX.

What does UNIX have to do with POSIX?

UNIX served as the basis for the standard as it was more neutral so to speak. This is not to say that it is 100% compatible.

Is Windows supported?

In a way, we can say yes. If you read the standard carefully, you will find that the Linux kernel does not meet the 100% standard either. The big difference between Windows and Linux is that Windows has a much lower compatibility.

Note : MacOS since version 10.5 Leopard is certified as POSIX compliant.

What does it matter to the developer?

Usually when we are going to write a cross-platform program it is necessary to study which interfaces are implemented and which ones are not. We usually have libraries that handle these differences for the programmer.

It is very common today to avoid using Shell Script when targeting Windows, as it is not supported. That's why it's so common to see configuration scripts in Python or a shell script and a bat script.

Scroll to Top