Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.1 |
both |
#define _POSIX_SOURCE
#include <termios.h>
int tcsendbreak(int fildes, int duration);
Sends a break condition to a terminal (indicated by fildes) that is using asynchronous serial data transmission. tcsendbreak() sends a continuous stream of zero bits for the specified duration. tcsendbreak() is the usual method of sending a BREAK on a line.
If tcsendbreak() is issued against a pseudoterminal, this function has no effect.
If tcsendbreak() is called from a background process group against the caller's controlling terminal, a SIGTTOU signal may be generated depending how the process is handling SIGTTOUs:
Processing for SIGTTOU | System Behavior |
---|---|
Default or signal handler | The SIGTTOU signal is generated, and the function is not performed. tcsendbreak() returns -1 and sets errno to EINTR. |
Ignored or blocked | The SIGTTOU signal is not sent, and the function continues normally. |
If successful, tcsendbreak() returns 0.
⁄* CELEBT08
This example breaks terminal transmission.
*⁄
#define _POSIX_SOURCE
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
main() {
if (tcsendbreak(STDIN_FILENO, 100) != 0)
perror("tcsendbreak() error");
else
puts("break sent");
}