termios.4

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 4 代码 · 共 1,622 行 · 第 1/4 页

4
1,622
字号
.PPThe .PN tcgetattr() function retrieves the parameters associated with the objectreferred to by .I fildes and store them in the .PN termios structure referenced by.I termios_p .This function is allowed from a background process; however, theinformation can be subsequently changed by a foreground process..PPThe .PN tcsetattr() function sets the parameters associated with the terminalfrom the .PN termios structure referenced by .I termios_p as follows:.IP \(bu 5If .I optional_actions is TCSANOW, the change occurs immediately..IP \(buIf .I optional_actions is TCSADRAIN, the change occurs after alloutput written to .I fildes has been transmitted.  This function shouldbe used when changing parameters that affect output..IP \(buIf .I optional_actions is TCSADFLUSH, the change occurs after alloutput written to the object referred to by .I fildes has been transmitted,and all input that has been received but not read is discardedbefore the change is made..PP.B Returns.PPUpon successful completion, a value of zero is returned.  Otherwise, a valueof \-1 is returned and .I errno is set to indicate the error..PP.B Errors.PPIf any of the following conditions occur, the .PN tcgetattr() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"The device does not support the .PN tcgetattr() function..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..PPIf any of the following conditions occur, the .PN tcsetattr() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"The device does not support the .PN tcsetatr() function, or the .I optional_actions argument is not a proper value..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..PP.B Line Control Functions.PPFunctions: .PN tcsendbreak() , .PN tcdrain() , .PN tcflush() , .PN tcflow().PP.B Syntax.EX#include <termios.h>int tcsendbreak (fildes, duration)int fildes;int duration;int tcdrain (fildes)int fildes;int tcflush (fildes, queue_selector)int fildes;int queue_selector;int tcflow (fildes, action)int fildes;int action;.EE.B Description.PPThe .PN tcsendbreak() function sends a ``break'' that is a continuous stream of zero-valued bits for a specific duration.  If durationis zero, it sends zero-valued bits for 0.25 seconds.  If duration isgreater than zero, it sends zero-valued bits for duration*0.1 seconds.If the object referred to by .I fildes .is not an asynchronous serial connection,no break sequence is generated..PPThe .PN tcdrain() function waits until all output written to the object referred to by .I fildes has been transmitted..PPThe .PN tcflush() function discards data written to the object referred to by.I fildes but not transmitted, or data received but not read, depending on the value of .I queue_selector:.IP \(bu 5If .I queue_selector is TCIFLUSH, it flushes data received but not read..IP \(bu 5If .I queue_selector is TCOFLUSH, it flushes data written but nottransmitted..IP \(bu 5If .I queue_selector is TCIOFLUSH, it flushes both data received but notread, and data written but not transmitted..PPThe .PN tcflow() function suspends transmission or reception of data on the object referred to by .I fildes , depending on the value of .I action:.IP \(bu 5If .I action is TCOOFF, it suspends output..IP \(bu 5If .I action is TCOON, it restarts suspended output..IP \(bu 5If .I action is TCIOFF, the system transmits a STOP character, which isintended to cause the terminal device to stop transmitting data to thesystem..IP \(bu 5If .I action is TCION, the system transmits a START character, which isintended to cause the terminal device to resume transmitting data to thesystem..IP \(bu 5The default on open of a terminal file is that neither its input nor itsoutput is suspended.  .PP.B Returns.PPUpon successful completion, a value of zero is returned.  Otherwise, a valueof \-1 is returned and .I errno is set to indicate the error..PP.B Errors.PPIf any of the following conditions occur, the .PN tcsendbreak() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP" The device does not support the .PN tcsendbreak() function..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..PPIf any of the following conditions occur, the .PN tcdrain() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"The device does not support the .PN tcdrain() function..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..IP "\fB[EINTR]\fP"A signal interrupted the .PN tcdrain() function..PPIf any of the following conditions occur, the .PN tcflush() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"The device does not support the .PN tcflush() function, or the .I queue_selector argument is not a proper value..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..PPIf any of the following conditions occur, the .PN tcflow() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"The device does not support the .PN tcflow() function, or the.I action argument is not a proper value..IP "\fB[ENOTTY]\fP"The file associated with .I fildes is not a terminal..PP.B Get Foreground Process Group Id.PPFunction: .PN tcgetpgrp().PP.B Synopsis.EX #include <sys/types.h>#include <termios.h>pid_t tcgetpgrp (fildes)int fildes;.EE.B Description.PPThe .PN tcgetpgrp() function returns the value of the process group ID of theforeground process group associated with the terminal..PPThe .PN tcgetpgrp() function is allowed from a background process; however, theinformation can be subsequently changed by a foreground process..PP.B Returns.PPUpon successful completion, .PN tcgetpgrp() retuns the process group ID of theforeground process group associated with the terminal.  Otherwise, a valueof \-1 is returned and .I errno is set to indicate the error..PP.B Errors.PPIf any of the following conditions occur, the .PN tcgetpgrp() function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"This function is not allowed for the device associated with the .I fildes argument..IP "\fB[ENOTTY]\fP"The calling process does not have a controlling terminal or the file isnot the controlling terminal..PP.B Set Foreground Process Group ID.PPFunction: .PN tcsetpgrp().PP.B Synopsis.EX#include <sys/types.h>#include <termios.h>int tcsetpgrp (fildes, pgrp_id)int fildes;pid_t pgrp_id;.EE.PP.B Description.PPIf the process has a controlling terminal, the .PN tcsetpgrp() function setsthe foreground process group ID associated with the terminal to .I pgrp_id.The file associated with .I fildes must be the controlling terminal of the calling process,  and the controlling terminal must be currently associated with the sessionof the calling process.  The value of .I pgrp_id must match a process groupID of a process in the same session as the calling process..PP.B Returns.PPUpon successful completion, .PN tcsetpgrp() returns a value of zero.  Otherwise, avalue of \-1 is returned and .I errno is set to indicate the error..PP.B Errors.PPIf any of the following conditions occur, the .PN tcsetpgrp()function returns \-1 and sets .I errno to the corresponding value:.IP "\fB[EBADF]\fP" 12The .I fildes argument is not a valid file descriptor..IP "\fB[EINVAL]\fP"This function is not allowed for the device associated with the.I fildes argument or the value of .I pgrp_id argument is less than orequal to zero, or exceeds {PID_MAX}..IP "\fB[ENOTTY]\fP"The calling process does not have a controlling terminal or the fileis not the controlling terminal, or the controlling terminal is no longer associated with the session of the calling process..IP "\fB[EPERM]\fP"The value of the .I pgrp_id argument does not match the process group ID of a process in the same session as the calling process..RE.SH See Alsocsh(1), stty(1), tset(1), ioctl(2), sigvec(2), setsid(2), termio(4), getty(8)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?