1tcsetattr(3C) Standard C Library Functions tcsetattr(3C)
2
3
4
6 tcsetattr - set the parameters associated with the terminal
7
9 #include <termios.h>
10
11 int tcsetattr(int fildes, int optional_actions,
12 const struct termios *termios_p);
13
14
16 The tcsetattr() function sets the parameters associated with the termi‐
17 nal referred to by the open file descriptor fildes (an open file
18 descriptor associated with a terminal) from the termios structure (see
19 termio(7I)) referenced by termios_p as follows:
20
21 o If optional_actions is TCSANOW, the change will occur imme‐
22 diately.
23
24 o If optional_actions is TCSADRAIN, the change will occur
25 after all output written to fildes is transmitted. This
26 function should be used when changing parameters that affect
27 output.
28
29 o If optional_actions is TCSAFLUSH, the change will occur
30 after all output written to fildes is transmitted, and all
31 input so far received but not read will be discarded before
32 the change is made.
33
34
35 If the output baud rate stored in the termios structure pointed to by
36 termios_p is the zero baud rate, B0, the modem control lines will no
37 longer be asserted. Normally, this will disconnect the line.
38
39
40 If the input baud rate stored in the termios structure pointed to by
41 termios_p is 0, the input baud rate given to the hardware will be the
42 same as the output baud rate stored in the termios structure.
43
44
45 The tcsetattr() function will return successfully if it was able to
46 perform any of the requested actions, even if some of the requested
47 actions could not be performed. It will set all the attributes that
48 implementation supports as requested and leave all the attributes not
49 supported by the implementation unchanged. If no part of the request
50 can be honoured, it will return −1 and set errno to EINVAL. If the
51 input and output baud rates differ and are a combination that is not
52 supported, neither baud rate is changed. A subsequent call to tcge‐
53 tattr(3C) will return the actual state of the terminal device (reflect‐
54 ing both the changes made and not made in the previous tcsetattr()
55 call). The tcsetattr() function will not change the values in the
56 termios structure whether or not it actually accepts them.
57
58
59 The effect of tcsetattr() is undefined if the value of the termios
60 structure pointed to by termios_p was not derived from the result of a
61 call to tcgetattr(3C) on fildes; an application should modify only
62 fields and flags defined by this document between the call to tcge‐
63 tattr(3C) and tcsetattr(), leaving all other fields and flags unmodi‐
64 fied.
65
66
67 No actions defined by this document, other than a call to tcsetattr()
68 or a close of the last file descriptor in the system associated with
69 this terminal device, will cause any of the terminal attributes defined
70 by this document to change.
71
72
73 Attempts to use tcsetattr() from a process which is a member of a back‐
74 ground process group on a fildes associated with its controlling termi‐
75 nal, will cause the process group to be sent a SIGTTOU signal. If the
76 calling process is blocking or ignoring SIGTTOU signals, the process is
77 allowed to perform the operation, and no signal is sent.
78
80 If trying to change baud rates, applications should call tcsetattr()
81 then call tcgetattr(3C) in order to determine what baud rates were
82 actually selected.
83
85 Upon successful completion, 0 is returned. Otherwise, −1 is returned
86 and errno is set to indicate the error.
87
89 The tcsetattr() function will fail if:
90
91 EBADF The fildes argument is not a valid file descriptor.
92
93
94 EINTR A signal interrupted tcsettattr().
95
96
97 EINVAL The optional_actions argument is not a supported value, or an
98 attempt was made to change an attribute represented in the
99 termios structure to an unsupported value.
100
101
102 ENOTTY The file associated with fildes is not a terminal.
103
104
105
106 The tcsetattr() function may fail if:
107
108 EIO The process group of the writing process is orphaned, and the
109 writing process is not ignoring or blocking SIGTTOU.
110
111
113 See attributes(5) for descriptions of the following attributes:
114
115
116
117
118 ┌─────────────────────────────┬───────────────────────────────┐
119 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
120 ├─────────────────────────────┼───────────────────────────────┤
121 │Interface Stability │Standard │
122 ├─────────────────────────────┼───────────────────────────────┤
123 │MT-Level │MT-Safe, and Async-Signal-Safe │
124 └─────────────────────────────┴───────────────────────────────┘
125
127 cfgetispeed(3C), tcgetattr(3C), attributes(5), standards(5), termio(7I)
128
129
130
131SunOS 5.11 14 Aug 2002 tcsetattr(3C)