9

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.

2
  • 1
    Why downvoted? This is a fairly reasonable question. At least I didn't know I should install the the manual for the library that implements the interface. before someone told me so.
    – Rick
    Apr 9, 2019 at 8:43
  • 1
    Many thanks to @Kusalananda resolving my confusion. See discussion from chat.stackoverflow.com/rooms/191520/…, hope that also help you.
    – Rick
    Apr 9, 2019 at 11:30

2 Answers 2

11

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.

5
  • Another question, why pthread_create is included in the Linux Programmer's Manual, while some other like pthread_mutex_lock is not? Why?
    – Rick
    Apr 9, 2019 at 8:22
  • @Rick the glibc manpages include one for pthread_mutex_lock: manpages.ubuntu.com/manpages/cosmic/en/man3/…
    – muru
    Apr 9, 2019 at 8:31
  • @Rick The manual for pthread_create() seems to be included in manpages-dev. I don't know why the manuals are divided between the packages in this way.
    – Kusalananda
    Apr 9, 2019 at 10:18
  • So the posix manual is the standard manual, while the glibc-doc and Linux Programmer's Manual is the implementation manual ? So when I checking the usage by man 3 printf on Ubuntu, I am checking the GNU C (glibc)'s documentation, not the standard like from cppference.
    – Rick
    Apr 9, 2019 at 10:42
  • @Rick cppreference isn't official. It's community maintained (pretty good, but still not officially maintained by the standards body)
    – muru
    Apr 9, 2019 at 11:14
2

As of Arch Linux, the package is man-pages from core. Take fcntl for example, after installing man-pages, man 2 fcntl gives the Linux Programmer's Manual page while man 3 fcntl and man fcntl gives the POSIX Programmer's Manual.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .