[Bug 72200] ioctl(TCSBRK, 1) on socket yields EFAULT (expected EINVAL/ENOTTY)

Jörg Höhle Joerg-Cyril.Hoehle at T-Systems.com
Mon Nov 27 14:44:42 UTC 2006

I was told the Linux kernel hackers want code that goes straight to the
bones, i.e. use ioctl() instead of the tcdrain() wrapper. Here it is.

/* tcdrain() returns EFAULT (a serious error) on sockets
 * tcdrain() is equivalent to ioctl(TCSBRK) on Linux and Solaris
#include <sys/ioctl.h>
#include <termios.h>            /* TCSBRK is 0x5409 */
#include <errno.h>
#include <stdio.h>

int main () {
  int i;
  for (i=0; i<=2; i++) {
    int retval, save;
    errno = 0;
    retval = ioctl(i,TCSBRK,1);
    save = errno;
    /* printf("ioctl(%d,TCSBRK,1)=(%d,%d=%s)\n",i,retval,save,
	   save ? strerror(save) : ""); */
  return 0;

tcdrain() on socket yields EFAULT (expected EINVAL/ENOTTY)

More information about the kernel-bugs mailing list