tcsendbreak() — Send a break condition to a terminal

Standards

Standards / Extensions C or C++ Dependencies

POSIX.1
XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _POSIX_SOURCE
#include <termios.h>

int tcsendbreak(int fildes, int duration);

General description

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.

Returned value

If successful, tcsendbreak() returns 0.

If unsuccessful, tcsendbreak() returns -1 and sets errno to one of the following values:
Error Code
Description
EBADF
fildes is not a valid open file descriptor.
EINTR
A signal interrupted tcsendbreak().
EIO
The process group of the process issuing the function is an orphaned, background process group, and the process issuing the function is not ignoring or blocking SIGTTOU.
ENOTTY
fildes is not associated with a terminal.

Example

CELEBT08
⁄* 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");
}

Related information