Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3)

tty(7)

termios(4)

getpass(3)  —  Subroutines

NAME

getpass − Reads a password

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <unistd.h>

char ∗getpass(
        const char ∗prompt);

PARAMETERS

promptPoints to the prompt string that is written to stderr. 

DESCRIPTION

The getpass() function opens the controlling terminal file, flushes output, disables echoing, and reads up to a newline character or an (EOF) End-of-File character from the /dev/tty file.  The terminal state is then restored and the controlling terminal is closed. 

If the getpass() function is interrupted by the SIGINT signal, the terminal state of /dev/tty is restored before the signal is delivered to the calling process. 

NOTES

The getpass() function is not threadsafe because it manipulates global signal state. 

AES Support Level:
Trial use.

RETURN VALUES

Upon successful completion, the getpass() function returns a pointer string of no more than PASS_MAX characters plus a terminating null value. This return value points to data that is overwritten by successive calls. If the controlling terminal file cannot be opened, a null pointer is returned. 

FILES

/dev/ttySpecifies the tty device special file. 

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]Search permission is denied on a component of the pathname prefix; or the file exists and the permissions specified by the mode parameter are denied; or the file does not exist and write permission is denied for the parent directory of the file to be created. 

[EINTR]The function was interrupted by a signal that was caught. 

[EMFILE]The OPEN_MAX file descriptors are currently open in the calling process. 

[ENFILE]Too many files are currently open in the system. 

[ENOENT]The named file does not exist or the path parameter points to an empty string. 

[ENXIO]The named file is a character-special or block-special file and the device associated with this special file does not exist. 

RELATED INFORMATION

Functions: fopen(3). 

Files: tty(7), termios(4). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026