Project

General

Profile

Actions

Bug #3252

open

tcsetattr/tcgetattr set errno incorrectly on non-TTY

Added by tonyc over 3 years ago. Updated over 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
10/26/2020
Due date:
% Done:

0%

Estimated time:

Description

tcsetattr() and tcgetattr() are documented to fail as follows:

Upon successful completion, the functions tcgetattr() and tcsetattr()
return a value of 0. Otherwise, they return -1 and the global variable
errno is set to indicate the error, as follows:

...

[ENOTTY]           The file associated with the fd argument to
tcgetattr() or tcsetattr() is not a terminal.

which matches POSIX, but they do not set errno correctly:

$ cc -otcerror tcerror.c
$ ./tcerror
OK: tcgetattr on /dev/null failed as expected
FAIL: tcgetattr on /dev/null set errno incorrectly: Operation not supported by device
OK: tcsetattr failed as expected
FAIL: tcsetattr failure set errno incorrectly: Operation not supported by device
$ uname -a
DragonFly 5.8-RELEASE DragonFly v5.8.3-RELEASE #10: Thu Sep 24 19:19:45 EDT 2020 :/usr/obj/home/justin/release/5_8/sys/X86_64_GENERIC x86_64

This was discovered while diagnosing perl test failures.


Files

tcerror.c (1.03 KB) tcerror.c test code tonyc, 10/25/2020 09:35 PM
Actions #1

Updated by tonyc over 3 years ago

The same issue applies to tcdrain(), tcflow(), tcflush() and tcsendbreak().

Actions

Also available in: Atom PDF