Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (t - v) tcdrain(3)
NAME
tcdrain - Waits for output to finish
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
SYNOPSIS
#include <termios.h>
int tcdrain(
int filedes);
PARAMETERS
filedes Specifies an open file descriptor.
DESCRIPTION
The tcdrain( ) function waits until all output written to the object referred to by the filedes
parameter has been transmitted.
The tcdrain( ) function, which suspends the calling process until the request is completed, is
redefined so that only the calling thread is suspended.
Attempts to use the tcdrain( ) function from a process that is a member of a background process
group on a filedes associated with its controlling terminal causes the process group to be sent a
SIGTTOU signal. If the calling process is blocking or ignoring the SIGTTOU signal, the pro-
cess is allowed to perform the operation and no signal is sent.
EXAMPLES
To wait until all output has been transmitted, enter:
rc = tcdrain(stdout);
RETURN VALUES
Upon successful completion, the value 0 (zero) is returned. Otherwise, the value -1 is returned
and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the tcdrain( ) function sets errno to the corresponding
value:
[EBADF] The filedes parameter does not specify a valid file descriptor.
[EINTR] A signal interrupted the tcdrain( ) function.
[EIO] One of the following conditions exists:
The process group of the caller is orphaned and the caller is not ignoring
or blocking the SIGTTOU signal.
An input or output error occurred. The device holding the terminal file
might be in the down state, or both processors that provide access to the
device might have failed.
[EISGUARDIAN]
The value used for the filedes parameter is appropriate only in the Guardian
environment.
527187-017 Hewlett-Packard Company 79