18

Why are most Linux distributions not POSIX-compliant? I've seen in lots of places that they're not (e.g. Mostly POSIX-compliant) but there's been no real explanation to back this up.

Is there something the C library and/or tools could do to get around this (i.e. no modifications to the kernel itself)? What needs to be done?

The supposed duplicate is asking which Linux distribution is POSIX-compliant; this is asking why most Linux distributions aren't POSIX-compliant. I'm asking for specific details (i.e. some function or command isn't compliant), not the reasons the specific distributions don't (try to) get certified.

This comment from @PhilipCouling (thanks!) explains it well:

Compliance and certification are different subjects. The answers point to cost of (re)certification which is irrelevant to the subject of (non)compliance.

S.S. Anne
  • 482
  • 1
    There is at least one Linux distribution which is POSIX compliant, Inspur K-UX. – Stephen Kitt Jun 02 '19 at 04:44
  • 6
    @Gilles This is not a duplicate; the supposed duplicate is asking which Linux distro is POSIX-compliant; this is asking why Linux isn't POSIX-compliant. – S.S. Anne Jun 02 '19 at 17:37
  • @JL2210, the second sentence of the duplicate is "What are the primary reasons that most distributions don't get certified?" and answers there address that. – Jeff Schaller Jun 02 '19 at 18:06
  • 1
    @JeffSchaller I'm asking for specific details (i.e. some function or command isn't compliant), not the reasons they don't try to get certified. – S.S. Anne Jun 02 '19 at 18:20
  • 3
    @JeffSchaller Compliance and certification are different subjects. The answers point to cost of (re)certification which is irrelevant to the subject of (non)compliance. – Philip Couling Jun 02 '19 at 21:29
  • When compliance requires the existence of /bin/cd, which will not have any effect when called, one might question why any particular distribution will strive to meet compliance standards. – doneal24 Dec 06 '19 at 18:15
  • @doneal24 I don't recall that the exact path required is /bin/cd, but it's used to test if you can change directories into a path without actually changing directories. It's probably meant to be used in other tasks, like shell scripting and writing Makefiles. – S.S. Anne Dec 06 '19 at 21:27
  • I noticed a "too broad" close vote on this. Is there any way that I can make this less broad? – S.S. Anne Dec 06 '19 at 21:31

1 Answers1

17

POSIX does not specify a kernel interface, so Linux is largely irrelevant. It does specify the system interface, various tools, and extensions to the C standard, which could exist on top of any kernel. It is not POSIX-compliant in the sense that it's not mentioned, or it is POSIX-compliant in the sense that it's not mentioned, at your option.

There are UNIX®-Certified Linux distributions, so it is certainly possible to have fully POSIX-compliant operating systems using Linux. Huawei's EulerOS is one that has and that you can buy if you'd like. Most of the rest haven't paid their money and so don't have access to the test suite to check conformance.

Whether they would satisfy it in practice is not clear, but some do try harder than others. I suspect that some of the BSDs are closer than most Linux distributions, but that's a guess: for example, I know that execlp("cd", "/", NULL) fails on most Linux distributions, but works on many BSDs and is required by POSIX.

Michael Homer
  • 76,565
  • Could someone easily get around this by just writing a cd program? – S.S. Anne Jun 02 '19 at 04:52
  • Sure, but it's unlikely that that's the only deviation, it's just an easy gratuitous compliance check I know off the top of my head. All of them are resolvable if someone made the effort. – Michael Homer Jun 02 '19 at 04:53
  • 1
    Is there any unofficial test suite? I was sort of hoping to test my C library for conformance; the POSIX standard seems a bit ambiguous on a few functions. – S.S. Anne Jun 02 '19 at 04:54
  • 1
    Not that I know of, but maybe. At that level of specificity "unofficial" probably doesn't really cut it, though. – Michael Homer Jun 02 '19 at 05:02
  • cd should be a binary in POSIX ..... quite impressive. Learnt somethng new everyday. – Sherry869 Feb 17 '21 at 14:03
  • 1
    What would a cd program even do? Change the directory and then exit? What would be the point? – Daniel Walker Apr 25 '22 at 11:35