POSIX Programmer’s Manual vs Linux Programmer’s Manual

man

I wanted to take a look at the manpage of pthread_mutex_trylock.

By typing man pthread_mutex_trylock, I got No manual entry for pthread_mutex_trylock.

Then I saw a post suggest doing sudo apt-get install manpages-posix manpages-posix-dev.

After that I see description like:

PTHREAD_MUTEX_LOCK(3POSIX)                               POSIX Programmer's Manual                              PTHREAD_MUTEX_LOCK(3POSIX)

PROLOG
       This manual page is part of the POSIX Programmer's Manual.  The Linux implementation of this interface may differ (consult the cor‐
       responding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
  1. What's the difference between this POSIX Programmer's Manual and the Linux Programmer's Manual that I usually see?

  2. What does it mean by saying:

The Linux implementation of this interface may differ (consult the
cor‐responding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

So where can I find the manpage for The Linux implementation of pthread_mutex_trylock ? Can I use pthread_mutex_trylock on my system ? I am using Ubuntu.

Best Answer

It says that because there's no guarantee that the POSIX manuals (for anything) corresponds to the actual implementation of the corresponding thing on your particular system.

To get the manual for pthread_mutex_trylock(), install the the manual for the library that implements the interface.

On Ubuntu systems, the required manual seems to be part of the glibc-doc package (found by searching for the function name on the Ubuntu package search pages).

The POSIX manual are definitely not useless. The local Linux interface should be compatible with the interface described in the POSIX manual, but the implementation-specific manual may also mentions caveats and Linux-specific implementation details and extensions, and similar non-POSIX functions.

The POSIX manuals becomes extra important if you are concerned about the portability of your code to other Unix systems, in which case you would want to avoid relying on Linux-specific extensions to the POSIX specification.

Related Question