tcsendbreak()

Updated: April 19, 2023

Assert a break condition over a communications line

Synopsis:

#include <termios.h>

int tcsendbreak( int filedes, 
                 int duration );

Arguments:

filedes
A file descriptor that's associated with the line that you want to assert the break on.
duration
The number of milliseconds that you want to break for.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The tcsendbreak() function asserts a break condition over the communication line associated with the opened file descriptor indicated by filedes.

The break condition lasts for at least duration milliseconds, or approximately 300 milliseconds if duration is zero. The system rounds the effective value of duration up to the next highest supported interval, which is typically a multiple of 100 milliseconds.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
The argument filedes is invalid.
ENOSYS
The resource manager associated with filedes doesn't support this call.
ENOTTY
The argument filedes doesn't refer to a terminal device.

Examples:

#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>

int main( void )
  {
    int fd;

    fd = open( "/dev/ser1", O_RDWR );

    /* Send a 500 millisecond break */
    tcsendbreak( fd, 500 );

    close( fd );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes