From Surf Wiki (app.surf) — the open knowledge base
Not a typewriter
Unix error code
Unix error code

In computing, "Not a typewriter" or ENOTTY is an error code defined in the errno.h found on many Unix systems. This code is now used to indicate that an invalid ioctl (input/output control) number was specified in an ioctl system call.
Details
This error originated in early UNIX. In Version 6 UNIX and earlier, I/O control was limited to serial-connected terminal devices, typically a teletype (abbreviated TTY), through the gtty and stty system calls. If an attempt was made to use these calls on a non-terminal device, the error generated was ENOTTY. When the stty/gtty system calls were replaced with the more general ioctl (I/O control) call, the ENOTTY error code was retained.
Early computers and Unix systems used electromechanical typewriters as terminals. The abbreviation TTY, which occurs widely in modern UNIX systems, stands for "Teletypewriter." For example, the original meaning of the SIGHUP signal is that it Hangs UP the phone line on the teletypewriter which uses it. The generic term "typewriter" was probably used because "Teletype" was a registered trademark of AT&T subsidiary Teletype Corporation and was too specific. The name "Teletype" was derived from the more general term "teletypewriter"; using "typewriter" was a different contraction of the same original term.
POSIX sidesteps this issue by describing ENOTTY as meaning "not a terminal".
Because ioctl is now supported on other devices than terminals, some systems display a different message such as "Inappropriate ioctl for device" instead.
Occurrence
In some cases, this message will occur even when no ioctl has been issued by the program. This is due to the way the isatty() library routine works. The error code errno is only set when a system call fails. One of the first system calls made by the C standard I/O library is in an isatty() call used to determine if the program is being run interactively by a human (in which case isatty() will succeed and the library will write its output a line at a time so the user sees a regular flow of text) or as part of a pipeline (in which case it writes a block at a time for efficiency). If a library routine fails for some reason unrelated to a system call (for example, because a user name wasn't found in the password file) and a naïve programmer blindly calls the normal error reporting routine perror() on every failure, the leftover ENOTTY will result in an utterly inappropriate "Not a typewriter" (or "Not a teletype", or "Inappropriate ioctl for device") being delivered to the user.
For many years the UNIX mail program sendmail contained this bug: when mail was delivered from another system, the mail program was being run non-interactively. If the destination address was local, but referred to a user name not found in the local password file, the message sent back to the originator of the email was the announcement that the person they were attempting to communicate with was not a typewriter.
References
References
- "What does ENOTTY stand for?".
- [http://man.cat-v.org/unix-6th/2/ Version 6 UNIX manual, section 2, system calls]
- (November 3, 1971). "Unix Programmer's Manual".
- {{IETF RFC. 1, ''Host Software'', Steve Crocker (7 April 1969). Page 3, section "Simple use".
- "The Open Group Base Specifications Issue 7, 2018 edition/IEEE Std 1003.1-2017: isatty".
- "OpenBSD manual: intro, errno — introduction to system calls and error numbers".
- "FreeBSD manual: intro -- introduction to system calls and error numbers".
- "A/UX: mail and "not a typewriter" (2/95)".
This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.
Ask Mako anything about Not a typewriter — get instant answers, deeper analysis, and related topics.
Research with MakoFree with your Surf account
Create a free account to save articles, ask Mako questions, and organize your research.
Sign up freeThis content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.
Report