Listing 1: ctrlq.c
/* ctrlq.c
*
* Frees flow control and flushes a tty
* device.
*
* Make: cc -o ctrlq -O ctrlq.c
* Usage: ctrlq <tty_pathname>
* Example: ctrlq /dev/tty1d
*/
#include <stdio.h>
#include <fcntl.h>
#include <termio.h>
main( argc, argv )
int argc;
char **argv;
{
int fd;
int status;
if (argc < 2)
{
fprintf(stderr, "Usage:\t%s <tty_pathname>\n", argv[0]);
exit(1);
}
if ((fd = open(argv[1], O_RDWR | O_NDELAY)) < 0)
{
perror(argv[1]);
fprintf(stderr, "Usage:\t%s <tty_pathname>\n", argv[0]);
exit(1);
}
if (ioctl(fd, TCXONC, 1) < 0)
{
perror( "TCXONC" );
fprintf(stderr, "Usage:\t%s <tty_pathname>\n", argv[0]);
exit(1);
}
if (ioctl(fd, TCFLSH, 1) < 0)
{
perror( "TCFLSH" );
fprintf(stderr, "Usage:\t%s <tty_pathname>\n", argv[0]);
exit(1);
}
exit(0);
}
/* End of File */
|