Is Mac OS X a POSIX OS?
Asked Answered
F

5

87

What is it that makes an OS a POSIX system? All versions of Linux are POSIX, right? What about Mac OS X?

Fiveandten answered 26/4, 2011 at 3:14 Comment(0)
E
106

Is Mac OS X a POSIX OS?

Yes.

POSIX is a group of standards that determine a portable API for Unix-like operating systems. Mac OS X is Unix-based (and has been certified as such), and in accordance with this is POSIX compliant. POSIX guarantees that certain system calls will be available.

Essentially, Mac satisfies the API required to be POSIX compliant, which makes it a POSIX OS.

All versions of Linux are not POSIX-compliant. Kernel versions prior to 2.6 were not compliant, and today Linux isn't officially POSIX-compliant because they haven't gone out of their way to get certified (which will likely never happen). Regardless, Linux can be treated as a POSIX system for almost all intents and purposes.

Extravascular answered 26/4, 2011 at 3:16 Comment(13)
@z-buffer you can rely on certain system calls to be available, e.g. stat(), read(), etc.Extravascular
There are many versions of Linux systems. Is it because of Linux that POSIX was created?Fiveandten
"All versions are not" here means "No versions are" — rather than "Not all versions are" or "Some versions are". Right?Sethrida
@Sethrida Linux is not truly POSIX compliant because they're not certified, and they never have been. So the existing wording is most correct.Extravascular
@Rafe: That’s what I thought. I was just making sure, is all.Sethrida
@Sethrida no problem. Wording is important.Extravascular
@z-buffer: "Is it because of Linux that POSIX was created?" No. First POSIX standard 1988. Mr. Torvalds begins developement of Linux, 1991. en.wikipedia.org/wiki/Posix#Name en.wikipedia.org/wiki/Linux#History. As I remember, POSIX grew out of need to write portable Unix apps across AT&T Unix, BSD Unix, etc.Belk
Important related fact: Mac uses the BSD implementation of the POSIX utils, not the GNU one like Linux does.Diaz
Please note that OSX POSIX implementation is old, so newer POSIX software might not compile.Receptor
@CiroSantilli巴拿馬文件六四事件法轮功 What are the differences between GNU and BSD utils? If I'm understanding correctly, POSIX states an OS must have certain utilities, and then the OS implements it. OSX uses BSD implementations and some linux distros use the GNU implementations? Are these utilities system calls, because I thought system calls were part of the kernelCrystallization
@Abdul system calls are part of the kernel, and in Linux they only have an assembly official interface, not C. POSIX does not specify any assembly interface, only C, so POSIX does not specify anything about the Linux kernel itself. In practice however, if the OS is not made to support POSIX, it is hard to do it efficiently. GNU glibc implements the POSIX C API, often by wrapping kernel assembly system calls into C. I don't know anything about BSD, but I imagine that the situation is similar.Diaz
For all intents and purposes, for most developers, both UNIX and POSIX is equal to Linux. Technically this definitely isn't true though, and both officially and in practice, Linux is neither a UNIX nor POSIX.Literacy
@RafeKettler, Re "to be available"; Just available?Sorehead
L
14

Yes, OS X is based on Darwin BSD, and since 10.5 (Leopard - 18-May-2007) all Intel/AMD versions have been officially certified as compliant with the Unix 03 / POSIX standard eg.

Lungfish answered 21/11, 2015 at 3:27 Comment(0)
M
10

No, it is not. MacOS is missing a whole bunch of features of POSIX, like clock_nanosleep(). It might be compliant with a subset of POSIX or with a really really old version of POSIX, but it's definitely not compliant with POSIX.1-2017. See http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html.

Marmara answered 19/6, 2019 at 19:5 Comment(1)
I have also found a non-compliance bug in OS/X. Signals are supposed to be delivered to the first thread that either un-masks the signal or calls sigwait on the signal. In OS/X, when a signal is sent to a process and it was masked in all threads, the signal is effectively pre-assigned to one thread -- sigpending() shows it present in only one thread! (sigpending is supposed to show the same result in every thread). If the unassigned thread then un-masks, nothing happens. If sigwait is called by the unassigned thread, it succeeds, so it gets this one thing right.Blameless
G
4

OSX POSIX

Single UNIX Specification(SUS). It is a set of standards to use UNIX mark.

Portable Operating System Interface(POSIX) - it is a subset of SUS. It defines API between OS and application as long as others tools and utilities. It includes such parts as Process, IO, Threads, security, Shell

UNIX 03 is a Product Standard mark which conforms SUS v3

Latest Apple Inc UNIX products

MAC OS(since 10.5 Leopard) is a UNIX 03 compliant OS which is certified by The Open Group.

Linux is a general name of a core for others operating system.

Linux is not POSIX-certified(except some of them like Huawei EulerOS - UNIX 03). But Linux is mostly POSIX-compliant because they try to stick to these standards and even more

Gingerich answered 2/3, 2021 at 16:41 Comment(0)
R
2

POSIX is a specification: http://www.unix.org/what_is_unix/single_unix_specification.html AFAIK, Linux adheres to the spec, but hasn't certified yet

Rustic answered 26/4, 2011 at 3:18 Comment(1)
There are some funny issues - for instance it is not enough for a program that tries to adhere to POSIX to merely specify _POSIX_C_SOURCE with a value of say 200809L to have the environment comply - I for one had trouble with the supposed GCC extension being the realpath function, which is specified by POSIX - unless I also specified a non-standard _XOPEN_SOURCE with a value of 700 the program had issues compiling. Not a biggie (the presence of the latter flag is no showstop for POSIX, but it is far less portable), but definitely a nag. See man 2 realpath.Conformation

© 2022 - 2024 — McMap. All rights reserved.