Linux Serial subsystem development
 help / color / mirror / Atom feed
* [regression] ENOTTY returned for tty fds
@ 2024-07-21 11:52 stsp
  2024-07-24  6:51 ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: stsp @ 2024-07-21 11:52 UTC (permalink / raw)
  To: linux-serial

Hi!

I've noticed that one of my progs failed
to work with serial ports. To distinguish
between real serial ports and PTS nodes,
it tried TIOCMBIC, checking errno for EINVAL.

Obviously that behaviour was changed
and now ENOTTY is returned. Besides
being backward-incompatible, I think this
is also wrong because isatty() returns 1
on such FDs.

Here's the test-case:
socat PTY,link=/tmp/ttyS20,raw,echo=0,b9600 
PTY,link=/tmp/ttyS21,raw,echo=0,b9600

Then run this program:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>

int main() {
   int fd, err;
   int data = TIOCM_DTR | TIOCM_RTS;
   fd = open("/tmp/ttyS20", O_NONBLOCK);
   if (fd == -1) {
     perror("open()");
     return 1;
   }
   err = ioctl(fd, TIOCMBIC, &data);
   if (err && errno == ENOTTY && isatty(fd))
     printf("Test FAILED: ENOTTY for tty fd\n");
   return 0;
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-07-31 16:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-21 11:52 [regression] ENOTTY returned for tty fds stsp
2024-07-24  6:51 ` Greg KH
2024-07-24  8:07   ` stsp
2024-07-24  9:08     ` Greg KH
2024-07-24  9:55       ` stsp
2024-07-24 10:15         ` Greg KH
2024-07-24 10:53           ` Herbert Xu
2024-07-24 10:58             ` Herbert Xu
2024-07-31 10:25               ` Greg KH
2024-07-31 16:12                 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox