Wait until all output has been transmitted to a device
#include <termios.h> int tcdrain( int fildes );
libc
The tcdrain() function waits until all output has been physically transmitted to the device associated with fildes, or until a signal is received.
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main( void )
{
int fildes;
fildes = open( "/dev/ser1", O_RDWR );
write( fildes, "ATH", 3 );
/* Wait for data to transmit before returning */
tcdrain( fildes );
close( fildes );
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |