
Using ttysw_output() shows that the text is simply output to the dummy terminal emu-
lator described by ttysw. ttysw_input() is useful for sending data as input to a pro-
gram running in the TTY subwindow. For example, a window-based front end for a text edi-
tor could be written where all the common functions such as Save and Next Page can be pro-
grammed into panel buttons. Selecting one of those panel buttons would cause a constant
string to be sent to the application to be processed as input. The write filename function in vi
could have a button that uses ttysw_input() to send the string (w!\n) to the TTY
subwindow containing the program.
9.3 Monitoring the Program in the TTY Subwindow
When you use the TTY_ARGV attribute to pass the name of a program to run to the TTY
subwindow, the program runs as a forked child process. If the attribute:
TTY_QUIT_ON_CHILD_DEATH
is set to TRUE, then the application exits when the forked program exits. But, by default, this
attribute is set to FALSE. You can use TTY_PID to monitor the state of the child process run-
ning in the TTY window via the Notifier using notify_set_wait3_func(). The cli-
ent’s wait3() function gets called when the state of the process in the TTY subwindow
changes:*
#include <sys/wait.h>
static Notify_value my_wait3();
...
ttysw = xv_create(base_frame, TTY,
TTY_ARGV, my_argv,
NULL);
child_pid = (int)xv_get(ttysw, TTY_PID);
notify_set_wait3_