Open System Services Library Calls Reference Manual (G06.28+, H06.05+)
getpass(3) OSS Library Calls Reference Manual
NAME
getpass - Reads a string of characters (such as a password) without echoing
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossesrl
H-series OSS processes: /G/system/zdllnnn/zossedll
SYNOPSIS
#include <unistd.h>
char *getpass(
const char *prompt);
PARAMETERS
prompt Points to the prompt string that is written to the controlling terminal.
DESCRIPTION
The getpass() function does the following:
• Opens the controlling terminal file
• Writes the contents of the prompt parameter to the controlling terminal file
• Disables echoing
• Reads up to a newline character or an EOF (end-of-file) character from the controlling
terminal file
• Restores the terminal state
• Closes the controlling terminal file
If the getpass() function is interrupted by the SIGINT signal, the terminal state of the control-
ling terminal is restored before the signal is delivered to the calling process.
NOTES
The getpass() function is not safe for use in threads because it manipulates global signal state.
RETURN VALUES
Upon successful completion, the getpass() function returns a pointer to a string of no more than
PASS_MAX bytes plus a terminating null value. This return value points to data that is overwrit-
ten by successive calls to the getpass() function.
If the controlling terminal file cannot be opened, a null pointer is returned.
ERRORS
If any of the following conditions occurs as a result of the getpass() function calling the
fopen("/dev/tty", "w+") function, the getpass() function sets errno to the corresponding value:
[EACCES] One of the following conditions exists:
• Search permission is denied on /dev.
• The controlling terminal exists but it cannot be written to.
[EINTR] The function was interrupted by a signal that was caught.
3−60 Hewlett-Packard Company 527187-007