child of ttysw initialization

Chuck Musciano chuck at trantor.harris-atd.com
Sat Jan 7 17:20:27 AEST 1989


> I need to know how to send initialization information to a program running
> in a tty-subwindow in suntools. [...] The child program takes a bit of time
> to load, then sends several lines of messages, then waits for input. At that
> point, and not before, I need to send a short string.  After that all works
> fine.

Well, I have had some (distasteful) experiences with this aspect of Sun
View.

There are several race conditions in the firing up of tty window child
processes.  The worst one is that the starting of the child is
asynchronous with respect to the creation of the containing window.  If
the child gets up and running, and queries the window size (quite commonly
the first thing a lot of programs do), and the window has not yet been
rendered on the screen, the size is returned as two random numbers.  If
the window has been rendered, the size is correct.

I tried to fix this by creating and displaying the tty window, and then
(via window_set()) specifying the process to run.  Unfortunately, the
arguments passed to window_create() when the tty window is FIRST CREATED
are used to create the child.  If you don't supply a process to run, a
shell is created by default.  So there is no way to create the child
sometime after the window has been created.

My fix was to fork a stub process which spins, examining the window size
until it settles and matches some predetermined value.  It then execs the
desired child.  This is a gross kludge, and I wasn't happy about it.

In your case, you can use the ttysw_input() routine to send your commands
to the child.  They will be queued and delivered when the child does run.
There is no way to see the output of the child window, though.  I have
done this exact thing, and it worked.  Read the chapter on tty subwindows
in the Sun View manual.

Chuck Musciano
Advanced Technology Department
Harris Corporation
(407) 727-6131
ARPA: chuck at trantor.harris-atd.com



More information about the Comp.sys.sun mailing list