1 /* ioctl.cc: ioctl routines.
3 Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009
6 Written by Doug Evans of Cygnus Support
9 This file is part of Cygwin.
11 This software is a copyrighted work licensed under the terms of the
12 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
23 ioctl (int fd, int cmd, ...)
26 cygheap_fdget cfd (fd);
30 /* check for optional mode argument */
33 char *argp = va_arg (ap, char *);
36 debug_printf ("fd %d, cmd %x", fd, cmd);
38 /* FIXME: This stinks. There are collisions between cmd types
39 depending on whether fd is associated with a pty master or not.
40 Something to fix for Cygwin2. CGF 2006-06-04 */
41 if (cfd->is_tty () && cfd->get_major () != DEV_TTYM_MAJOR)
45 res = tcgetattr (fd, (struct termios *) argp);
48 res = tcsetattr (fd, TCSANOW, (struct termios *) argp);
51 res = tcsetattr (fd, TCSADRAIN, (struct termios *) argp);
54 res = tcsetattr (fd, TCSAFLUSH, (struct termios *) argp);
58 res = cfd->ioctl (cmd, argp);
61 debug_printf ("returning %d", res);