tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rfc: tcgetattr() error reporting



Hello.

I'm not so familiar with termios in NetBSD especially for /dev/null.
I tried to find appropriate *ioctl() code which setups that error, but
without success.
The tcgetattr(</dev/null>) probably should set errno to ENOTTY instead
of EOPNOTSUPP.

Here is small test case:

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

int main()
{
        int fd, rc;
        struct termios t;
        fd = open("/dev/null", O_RDONLY);
        errno=0;
        /*rc = tcgetattr(fd, &t);*/
#ifdef __linux__
        rc = ioctl(fd, TCGETS, &t);
#elif defined(__NetBSD__)
        rc = ioctl(fd, TIOCGETA, &t);
#else
        rc = -1;
#endif
        printf("rc: %d, err: %d, ENOTTY: %d\n", rc, errno, ENOTTY);
        close(fd);
        return 0;
}

Results (linux/NetBSD)

andy@FITFIESPPC176:~/tmp/base-ts$ ./termios1
rc: -1, err: 25, ENOTTY: 25

10:25 tmp$ ./termios1
rc: -1, err: 45, ENOTTY: 25

-- 
With Best Regards,
Andy Shevchenko


Home | Main Index | Thread Index | Old Index