Thread (4 messages) 4 messages, 3 authors, 2025-11-06

tcgetattr() can set errno to 22 / EINVAL

From: Дилян Палаузов <hidden>
Date: 2025-11-03 12:46:43

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.

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
  Дилян
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help