Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretation for IEEE Std 1003.1™-2001 IEEE Standard Standard for Information Technology -- Portable Operating System Interface (POSIX®)

Copyright © 2006 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.

Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.

IEEE Standards Department Copyrights and Permissions 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA

Interpretation Request #81
Topic: getgrnam_r return value Relevant Sections: XSH getgrnam_r

For both getgrnam and getgrnam_r the specification is a bit unclear in terms what is returned, when no entry has been found.


SUSv3: "The getgrnam() function shall return a null pointer if either the requested entry was not found, or an error occurred. On error, errno shall be set to indicate the error."

Ok, I'd expect that getgrnam("noExist") == NULL, but it is not clearly stated whether the errno may be changed or not. I read this as: errno stays that value and is not touched.

Others regard this a undefined by the spec. (GNU Libc maintainer: "The code always did signal a missing entry with a NULL pointer and ENOENT. There is nothing in POSIX which prohibits this. The POSIX spec just said what has to happen for the error condit


Description: "A NULL pointer is returned at the location pointed to by result on error or if the requested entry is not found."

Returned value: "If successful, the getgrnam_r() function shall return zero; otherwise, an error number shall be returned to indicate the error."

It is a bit unclear whether the error number is zero or not if entry has been found.

a) Clearify whether errno (getgrnam) is modified when no entry has been found
b) Clearify whether not found is "successful", i.e. whether zero is returned or not.

Interpretation Response
The standard is unclear on this issue and concerns have been raised about this which are being referred to the sponsor.

Rationale for Interpretation
The working group developers felt that the intent is that if no error occurs but an entry is not found, getgrnam() returns a null pointer and getgrnam_r() returns zero and set the pointer pointed to by result to a null pointer and neither getgrnam() nor getgrnam_r() should change errno in this case. If an error occurs, the return value is the same as stated except that the error indicate will also be set to indicate which error was detected.