
#include <termios.h> int tcsendbreak(int fileDescriptor, int duration);
tcsendbreak sends a break condition to a terminal.
fileDescriptor
duration
tcsendbreak function has no effect on
pseudoterminals.
tcsendbreak returns a 0 if successful and a -1 if unsuccessful.
If tcsendbreak is called from a background process, with a
file descriptor that refers to the controlling terminal for the
process, a SIGTTOU signal may be generated. This will cause
the function call to be unsuccessful, returning a -1 and
setting errno to EINTR. If SIGTTOU
is blocked, the function call proceeds normally.
tcsendbreak
to transmit a break condition to stdout:
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
int ttyDevice = STDOUT_FILENO;
int time = 15;
char * lineOut = "Break transmitted to terminal.";
/* Wait for all data transmission to the terminal to finish */
/* and then transmit a break condition to the terminal. */
if (tcdrain(ttyDevice) != 0) {
perror("tcdrain error");
return(EXIT_FAILURE);
}
else {
if (tcsendbreak(STDOUT_FILENO, time) != 0) {
perror("tcdsendbreak error");
return(EXIT_FAILURE);
}
else
write(ttyDevice, lineOut, strlen(lineOut) + 1);
}
return(EXIT_SUCCESS);
}
tcflow
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.