DEV Community

Cover image for What is POSIX?
wassef ben ahmed
wassef ben ahmed

Posted on

5 1

What is POSIX?

It sure sounds like a cool name!
POSIX stands for Portable Operating System Interface and is a family of standards, specified by the IEEE designed to facilitate application portability across UNIX based systems.

If you wrote your programs to rely on POSIX standards, you'll be able to port them easily among a large family of Unix derivatives.

Honorable mentions of UNIX SYSTEMS :
alt text

Some of the standards POSIX defines :


1.C API

Greatly extends STANDARD C with things like:

  • file operations: mkdir, dirname, symlink, readlink, link.
  • networking: socket().
  • memory management: mmap, mlock, mprotect, advise. Those APIs also determine the underlying system concepts on which they depend, forcing you to conform.

2.CLI utilities

E.g: cd, ls, echo ...
Many utilities are direct shell front ends for a corresponding C API functions and some are implemented by Bash as built-ins.

3.Shell language

Support for the shell language.
E.g :

a = 5;
echo "$a"; #to print the variable a.
Enter fullscreen mode Exit fullscreen mode

4.Program exit status

ANSI C says 0 or EXIT_SUCCESS for success, EXIT_FAILURE for failure.
what POSIX adds:

  • 126: command found but not executable.
  • 127: command not found.
  • >128: terminated by a signal.

5.Regular expression

Support for the two types of regex (BRE/ERE).
E.g :

echo 'a.1' | grep -E 'a.[[:digit:]]' 
#search for a regex from the piped input 
Enter fullscreen mode Exit fullscreen mode

6.Filenames

  • / is the path separator.
  • NUL cannot be used.
  • . is cwd, .. is parent.
  • can only contain a-zA-Z0-9._-

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more