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)\n",i,retval,save);
/* printf("ioctl(%d,TCSBRK,1)=(%d,%d=%s)\n",i,retval,save,
save ? strerror(save) : ""); */
}
return 0;
}
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 () { "ioctl( %d,TCSBRK, 1)=(%d, %d)\n", i,retval, save); "ioctl( %d,TCSBRK, 1)=(%d, %d=%s)\ n",i,retval, save,
int i;
for (i=0; i<=2; i++) {
int retval, save;
errno = 0;
retval = ioctl(i,TCSBRK,1);
save = errno;
printf(
/* printf(
save ? strerror(save) : ""); */
}
return 0;
}