mdb@silvlis.com (Mark D. Baushke) (02/09/89)
I received the following reply from Sun Software support which solves my problem. If you have not yet packaged my question into a sun-spots, please consider either adding this information or omitting the question entirely. Thank you, Mark D. Baushke Internet: mdb%silvlis.com@sun.com Silvar-Lisco, Inc. Nameservers: mdb@silvlis.com 1080 Marsh Road Usenet: {pyramid,sgi,sun}!silvlis!mdb Menlo Park, CA 94025-1053 Telephone: +1 415 853-6411 / +1 415 969-8328 ---------- Forwarded message From: sun!hvr (Heather Rose) Mark, The problem you're running into is that sunview programs change process groups in the first call to window_create(). You can work around this with something like this: int saved_pgrp; saved_pgrp = getpgrp(getpid()); frame = window_create (NULL,FRAME,0); setpgrp(getpid(), saved_pgrp); For just your first call to window_create(). Please try this and if it does not work out for you, please get back to me by 1/31/89. If I do not hear back from before before this time, I will assume all is working and close the service order 263289. Also, if you use vfork instead you can save on some temporary swap space. See the man page on fork. Regards, Heather Rose U.S. Answer Center ---------- end Forwarded message
mdb@silvlis.com (Mark D. Baushke) (02/14/89)
Problem summary: Reading from a stdin (attached to a tty) in a child process after opening and closing a sunview window fails. System Info: Sun 3/60 SunOS 3.x, Sun 4/260 SunOS 4.0.1 The shar file below contains the sources which demonstrate a problem I am having with the interaction of a simple sunview program with standard input. The files slave.c and master.c in this directory demonstrate a problem with mixing certain sunview programs with terminal I/O. The problem shows up when a graphic program wants to STOP doing graphics, and revert back to a 'stdin' / command-driven program. The program runs OK when invoked directly from the shell. When invoked through a parent process, it cannot read from stdin after the sunview window(s) have been closed. If run standalone, the "slave" program works correctly. It is able to read from stdin (connected to a tty) both before and after having created a sunview frame with the window_create() call. However, if the same program is run as a child process from "master", then it is still able to read from stdin before creating the sunview frame, but is no longer able to read from stdin afterwards. It "hangs" on the read and must be interrupted. to build, make now to run, type "slave" to see it run OK "master slave" to see it fail slave requires that you type a single char, followed by <cr> it then confirms that character, and opens a suntools window. You should 'QUIT' that window with the mouse. It then prompts again for another character. Two questions: 1. What is sunview doing ? 2. What is the minimum I need to do in 'master' so that slave will run OK ? Do I need to play with process groups ? with utmp ?? with something I have not yet heard of ??? .... I have an application which needs to wait for the child to finish and capture its status upon the completion of the child's task. It also needs to read input from stdin both before and after activity in the sunview frame. Does anyone have a suggested work around to this problem? (I suspect that either the window_create() or window_main_loop() procedures are using an ioctl TIOCNOTTY, but I do not know how to prevent this from happening or undo the behavior.) I will post a summary if there is sufficient interest. Thanks in advance, Mark D. Baushke Internet: mdb%silvlis.com@sun.com Silvar-Lisco, Inc. Nameservers: mdb@silvlis.com 1080 Marsh Road Usenet: {pyramid,sgi,sun}!silvlis!mdb Menlo Park, CA 94025-1053 Telephone: +1 415 853-6411 / +1 415 969-8328 [[ If you want to help Mr. Baushke, please retrieve the shar file he included. It is stored in the archives under "sun-spots" as "sunviewhelp.shar". It is 5785 bytes long -- a little long to include in a message given what it is. It can be retrieved via anonymous FTP from the host "titan.rice.edu" or via the archive server. For more information about the archive server, send a mail message containing the word "help" to the address "archive-server@rice.edu". --wnl ]]
mdb@silvlis.com (Mark D. Baushke) (02/23/89)
Please note that due to an apparent time warp of some kind, my original question was published after its solution was published. The original question was in Sun-Spots Digest: Volume 7, Issue 153, message 2 of 16 the solution was published in Sun-Spots Digest: Volume 7, Issue 144, message 5 of 9 If possible, please either delete sunviewhelp.shar or include the solution in that file. [[ I wonder how that happened. Sorry for the confusion. I have removed the shar file. --wnl ]] Problem/solution summary: Using stdin before creating a window and then again after the window no longer existed from a child process was not working. The problem is that sunview programs change process groups in the first call to window_create(). The work around should be something like this: int saved_pgrp; saved_pgrp = getpgrp(getpid()); frame = window_create (NULL,FRAME,0); setpgrp(getpid(), saved_pgrp); Thank you for anyone who may have obtained the shar file to try and help me out. Mark D. Baushke Internet: mdb%silvlis.com@sun.com Silvar-Lisco, Inc. Nameservers: mdb@silvlis.com 1080 Marsh Road Usenet: {pyramid,sgi,sun}!silvlis!mdb Menlo Park, CA 94025-1053 Telephone: +1 415 853-6411 / +1 415 969-8328 ---------- Forwarded message From: sun!hvr (Heather Rose) Mark, The problem you're running into is that sunview programs change process groups in the first call to window_create(). You can work around this with something like this: int saved_pgrp; saved_pgrp = getpgrp(getpid()); frame = window_create (NULL,FRAME,0); setpgrp(getpid(), saved_pgrp); For just your first call to window_create(). Please try this and if it does not work out for you, please get back to me by 1/31/89.... Also, if you use vfork instead you can save on some temporary swap space. See the man page on fork. Regards, Heather Rose U.S. Answer Center