Bug 204273 - sem_getvalue(3) man page misreports error conditions
Summary: sem_getvalue(3) man page misreports error conditions
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-22 13:16 UTC by gizero
Modified: 2020-04-23 15:06 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description gizero 2019-07-22 13:16:14 UTC
According to man page sem_getvalue() may return -1 on error and possibly set errno to EINVAL when the given semaphore is not valid. This seems to be inconsistent with the current glibc implementation which always return 0 (see comment on missing argument check at [1]).

Should we simply drop the reference to -1 return value and ERRORS from man page?

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/sem_getvalue.c;h=d33993d7ac2f4ac9c3ed550985e63ee47d54baa3;hb=HEAD
Comment 1 Michael Kerrisk 2020-04-23 09:24:28 UTC
This is tricky. POSIX allows for EINVAL, and portable applications may care about it.

It's true that glibc doesn't check for a valid semaphore, but maybe one day it might. In the source file that you refer to there is this comment:

    /* XXX Check for valid SEM parameter.  */

Admittedly, that comment has been there for a very long time, and nothing so far changed though.

I opted to add a sentence:

       EINVAL sem is not a valid semaphore.   (The  glibc  implementation
              currently does not check whether sem is valid.)

Closing this report now.
Comment 2 gizero 2020-04-23 15:06:33 UTC
Ok Michael, it makes sense! Thanks for looking at it.

Note You need to log in before you can comment on or make changes to this bug.