Path: utzoo!utgpu!attcan!uunet!lll-winken!ames!ncar!mailrus!husc6!rice!sun-spots-request From: chuck@trantor.harris-atd.com (Chuck Musciano) Newsgroups: comp.sys.sun Subject: Re: child of ttysw initialization Message-ID: <8901031316.AA21862@trantor.harris-atd.com> Date: 7 Jan 89 07:20:27 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 39 Approved: Sun-Spots@rice.edu Original-Date: Tue, 3 Jan 89 08:14:40 EST X-Sun-Spots-Digest: Volume 7, Issue 92, message 7 of 11 > 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@trantor.harris-atd.com