Print this page
12212 typos in some section 3tecla man pages
@@ -23,17 +23,16 @@
.\" Except as contained in this notice, the name of a copyright holder
.\" shall not be used in advertising or otherwise to promote the sale, use
.\" or other dealings in this Software without prior written authorization
.\" of the copyright holder.
.\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
-.TH GL_IO_MODE 3TECLA "Jun 1, 2004"
+.TH GL_IO_MODE 3TECLA "January 18, 2020"
.SH NAME
gl_io_mode, gl_raw_io, gl_normal_io, gl_tty_signals, gl_abandon_line,
gl_handle_signal, gl_pending_io \- use \fBgl_get_line()\fR from an external
event loop
.SH SYNOPSIS
-.LP
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-ltecla\fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libtecla.h>
\fBint\fR \fBgl_io_mode\fR(\fBGetLine *\fR\fIgl\fR, \fBGlIOMode\fR \fImode\fR);
@@ -69,12 +68,10 @@
.nf
\fBGlPendingIO\fR \fBgl_pending_io\fR(\fBGetLine *\fR\fIgl\fR);
.fi
.SH DESCRIPTION
-.sp
-.LP
The \fBgl_get_line\fR(3TECLA) function supports two different I/O modes. These
are selected by calling the \fBgl_io_mode()\fR function. The \fImode\fR
argument of \fBgl_io_mode()\fR specifies the new I/O mode and must be one of
the following.
.sp
@@ -101,15 +98,13 @@
.sp
.LP
Newly created GetLine objects start in normal I/O mode, so to switch to
non-blocking server mode requires an initial call to \fBgl_io_mode()\fR.
.SS "Server I/O Mode"
-.sp
-.LP
In non-blocking server I/O mode, the application is required to have an event
loop that calls \fBgl_get_line()\fR whenever the terminal file descriptor can
-perform the type I/O that \fBgl_get_line()\fR is waiting for. To determine
+perform the type of I/O that \fBgl_get_line()\fR is waiting for. To determine
which type of I/O \fBgl_get_line()\fR is waiting for, the application calls the
\fBgl_pending_io()\fR function. The return value is one of the following two
enumerated values.
.sp
.ne 2
@@ -124,11 +119,11 @@
.ne 2
.na
\fB\fBGLP_WRITE\fR\fR
.ad
.RS 13n
-\fBgl_get_line()\fR is waiting to read a character from the keyboad.
+\fBgl_get_line()\fR is waiting to read a character from the keyboard.
.RE
.sp
.LP
If the application is using either the \fBselect\fR(3C) or \fBpoll\fR(2)
@@ -160,12 +155,10 @@
\fIstart_pos\fR arguments of \fBgl_get_line()\fR will be ignored on these
calls. If you need to change the prompt of the line that is currently being
edited, you can call the \fBgl_replace_prompt\fR(3TECLA) function between calls
to \fBgl_get_line()\fR.
.SS "Giving Up The Terminal"
-.sp
-.LP
A complication that is unique to non-blocking server mode is that it requires
that the terminal be left in raw mode between calls to \fBgl_get_line()\fR. If
this were not the case, the external event loop would not be able to detect
individual key-presses, and the basic line editing implemented by the terminal
driver would clash with the editing provided by \fBgl_get_line()\fR. When the
@@ -197,12 +190,10 @@
Note that in non-blocking server mode, if \fBgl_get_line()\fR is called after a
call to \fBgl_normal_io()\fR, without an intervening call to \fBgl_raw_io()\fR,
\fBgl_get_line()\fR will call \fBgl_raw_mode()\fR itself, and the terminal will
remain in this mode when \fBgl_get_line()\fR returns.
.SS "Signal Handling"
-.sp
-.LP
In the previous section it was pointed out that in non-blocking server mode,
the terminal must be restored to a sane state whenever a signal is received
that either suspends or terminates the process. In normal I/O mode, this is
done for you by \fBgl_get_line()\fR, but in non-blocking server mode, since the
terminal is left in raw mode between calls to \fBgl_get_line()\fR, this signal
@@ -287,12 +278,10 @@
.sp
.LP
Depending on the signal that is being handled, this function does different
things.
.SS "Process termination signals"
-.sp
-.LP
If the signal that was caught is one of those that by default terminates any
process that receives it, then \fBgl_handle_signal()\fR does the following
steps.
.RS +4
.TP
@@ -323,12 +312,10 @@
5.
Finally it unblocks delivery of this signal, which results in the process
being terminated.
.RE
.SS "Process suspension signals"
-.sp
-.LP
If the default disposition of the signal is to suspend the process, the same
steps are executed as for process termination signals, except that when the
process is later resumed, \fBgl_handle_signal()\fR continues, and does the
following steps.
.RS +4
@@ -365,12 +352,10 @@
shells use this information to print a corresponding message to the terminal.
Users would be rightly confused if when their process received a \fBSIGPIPE\fR
signal, the program responded by sending itself a \fBSIGKILL\fR signal, and the
shell then printed out the provocative statement, "Killed!".
.SS "Interrupting The Event Loop"
-.sp
-.LP
If a signal is caught and handled when the application's event loop is waiting
in \fBselect()\fR or \fBpoll()\fR, these functions will be aborted with
\fBerrno\fR set to \fBEINTR\fR. When this happens the event loop should call
\fBgl_pending_io()\fR before calling \fBselect()\fR or \fBpoll()\fR again. It
should then arrange for \fBselect()\fR or \fBpoll()\fR to wait for the type of
@@ -463,11 +448,11 @@
Reinstate the signal handlers that were displaced in step 5.
.RE
.RS +4
.TP
11.
-Check wether a signal was caught, by checking the file-scope variable that
+Check whether a signal was caught, by checking the file-scope variable that
the signal handler records signal numbers in.
.RE
.RS +4
.TP
12.
@@ -479,12 +464,10 @@
.TP
13.
Unblock all of the signals that were blocked in step 7.
.RE
.SS "Signals Caught By \fBgl_get_line()\fR"
-.sp
-.LP
Since the application is expected to handle signals in non-blocking server
mode, \fBgl_get_line()\fR does not attempt to duplicate this when it is being
called. If one of the signals that it is configured to catch is sent to the
application while \fBgl_get_line()\fR is being called, \fBgl_get_line()\fR
reinstates the caller's signal handlers, then immediately before returning,
@@ -491,23 +474,19 @@
re-sends the signal to the process to let the application's signal handler
handle it. If the process is not terminated by this signal, \fBgl_get_line()\fR
returns \fINULL\fR, and a following call to \fBgl_return_status()\fR returns
the enumerated value \fBGLR_SIGNAL\fR.
.SS "Aborting Line Input"
-.sp
-.LP
Often, rather than letting it terminate the process, applications respond to
the \fBSIGINT\fR user-interrupt signal by aborting the current input line. This
can be accomplished in non-blocking server-I/O mode by not calling
\fBgl_handle_signal()\fR when this signal is caught, but by calling instead the
\fBgl_abandon_line()\fR function. This function arranges that when
\fBgl_get_line()\fR is next called, it first flushes any pending output to the
-terminal, discardes the current input line, outputs a new prompt on the next
+terminal, discards the current input line, outputs a new prompt on the next
line, and finally starts accepting input of a new input line from the user.
.SS "Signal Safe Functions"
-.sp
-.LP
Provided that certain rules are followed, the \fBgl_normal_io()\fR,
\fBgl_raw_io()\fR, \fBgl_handle_signal()\fR, and \fBgl_abandon_line()\fR
functions can be written to be safely callable from signal handlers. Other
functions in this library should not be called from signal handlers. For this
to be true, all signal handlers that call these functions must be registered in
@@ -528,12 +507,10 @@
block are the signals that \fBgl_get_line()\fR is currently configured to
catch, so be sure that if you call any of the above functions from signal
handlers, that the signals that these handlers are assigned to are configured
to be caught by \fBgl_get_line()\fR. See \fBgl_trap_signal\fR(3TECLA).
.SS "Using Timeouts To Poll"
-.sp
-.LP
If instead of using \fBselect()\fR or \fBpoll()\fR to wait for I/O your
application needs only to get out of \fBgl_get_line()\fR periodically to
briefly do something else before returning to accept input from the user, use
the \fBgl_inactivity_timeout\fR(3TECLA) function in non-blocking server mode to
specify that a callback function that returns \fBGLTO_CONTINUE\fR should be
@@ -546,12 +523,10 @@
The \fBgl_get_line()\fR function will not return until the user has not typed a
key for the specified interval, so if the interval is long and the user keeps
typing, \fBgl_get_line()\fR might not return for a while. There is no guarantee
that it will return in the time specified.
.SH ATTRIBUTES
-.sp
-.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
@@ -564,10 +539,8 @@
_
MT-Level MT-Safe
.TE
.SH SEE ALSO
-.sp
-.LP
\fBcpl_complete_word\fR(3TECLA), \fBef_expand_file\fR(3TECLA),
\fBgl_get_line\fR(3TECLA), \fBlibtecla\fR(3LIB), \fBpca_lookup_file\fR(3TECLA),
\fBattributes\fR(5), \fBtecla\fR(5)