Re: tcgetattr() can set errno to 22 / EINVAL
From: Alejandro Colomar <alx@kernel.org>
Date: 2025-11-03 13:21:00
Hi Дилян, On Mon, Nov 03, 2025 at 02:45:06PM +0200, Дилян Палаузов wrote:
Hello, please amend the errors at https://man7.org/linux/man-pages/man3/tcgetattr.3p.html that the function tcgetattr() can set errno to EINVAL 22 Invalid argument for /dev/hidraw files.
You should file a bug to the Austin Group, which is the group
responsible for the POSIX standard.
That manual page is just a formatted copy of the POSIX standard. See
the COPYRIGHT section:
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic
form from IEEE Std 1003.1-2017, Standard for Information
Technology -- Portable Operating System Interface (POSIX), The
Open Group Base Specifications Issue 7, 2018 Edition, Copyright
(C) 2018 by the Institute of Electrical and Electronics Engineers,
Inc and The Open Group. In the event of any discrepancy between
this version and the original IEEE and The Open Group Standard,
the original IEEE and The Open Group Standard is the referee
document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page
are most likely to have been introduced during the conversion of
the source files to man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .
IEEE/The Open Group 2017 TCGETATTR(3POSIX)
Have a lovely day!
Alex
Using kernel 6.6.60 on armv7l and libc 2.36 (where tcgetattr is implemented in termios/tcgetattr.c as ioctl(fd, TCGETS, …)), this program
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <termios.h>
void main() {
int fd = open("/dev/hidraw0", O_RDWR | O_NONBLOCK |O_NOCTTY);
struct termios s;
errno = 0;
int ret = tcgetattr(fd, &s);
printf("Returned fd is %i ret is %i errno is %i %m\n", fd, ret, errno);
}
puts:
Returned fd is 3 ret is -1 errno is 22 Invalid argument
Well at https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcgetattr.html Open Group Base Specifications Issue 8/year 2024 also says only EBADF and ENOTTY.
Kind regards
Дилян-- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>).
Attachments
- signature.asc [application/pgp-signature] 833 bytes