[comp.sys.sgi] problems with winopen

dieperink%uliis.unil.ch@CUNYVM.CUNY.EDU ("Alwin Dieperink, Assistant-Etudiant") (05/27/89)

Hi,

I have the following problem :

In the program here under, i want to open a window, and then continue to read
data from the keyboard. The data should be echoed in the shell window. (i want
to give the program commands to do some drawing in the window i opened).

I compiled the program as follow :

 cc test.c -o test -Zg

When i run the program, the window opens normally, and the text "t1" appears in
the shell window. But the shell prompt already got back, and i can't anymore
give data to my program.

When i do a ps from another window, i see that the process still lives. It dies
when i type two commands in my shell. I also noticed, that the PID is not
the same before and after the winopen. The PPID also changed. It was the shells
PID before winopen, and 1 after.

Does anyone have an idea ?? Why does winopen() create a new process ? How can I
solve that problem ? or did I miss something in the manuals ?

Thanks.

-- Alwin Dieperink

E-Mail : DIEPERINK@ULIIS.UNIL.CH
         DIEPERINK@ELMA.EPFL.CH
         ADIEPERI@CLSUNI51.BITNET

---------------------------------------------------

#include <stdio.h>
#include <gl.h>

main()
{
        int     c;

        prefposition(200,400,200,400);
        winopen("test window");
        printf("t1\n");

        c = getchar();
        while (c != EOF) {
                putchar(c);
                c = getchar();
        }
}

----------------------------------------------------

goss@SNOW-WHITE.MERIT-TECH.COM (Mike Goss) (05/30/89)

Regarding the message from Alwin Dieperink about winopen and processes:
	
> Does anyone have an idea ?? Why does winopen() create a new process ? How can I
> solve that problem ? or did I miss something in the manuals ?

Winopen normally does a fork to run as a separate process detached
from your original shell.  You can prevent this behavior by calling 
"foreground()" before calling winopen.  This is also useful if you are 
trying to use dbx or edge on a graphics process.

Mike Goss, Merit Technology Inc.

thant@horus.sgi.com (Thant Tessman) (05/30/89)

In article <890527165733.2080ecc2@SIC.Epfl.CH>, dieperink%uliis.unil.ch@CUNYVM.CUNY.EDU ("Alwin Dieperink, Assistant-Etudiant") writes:
> Hi,
> 
>I have the following problem :
> 
>In the program here under, i want to open a window, and then continue to read
>data from the keyboard. The data should be echoed in the shell window.
> (i want
> to give the program commands to do some drawing in the window i opened).
> 
> When i run the program, the window opens normally, 
> and the text "t1" appears in
> the shell window. But the shell prompt already got back, and i can't anymore
> give data to my program.
> 
> When i do a ps from another window, i see that the process still lives. 
>It dies
> when i type two commands in my shell. I also noticed, that the PID is not
> the same before and after the winopen. The PPID also changed. 
> It was the shells
> PID before winopen, and 1 after.
> 
> Does anyone have an idea ?? Why does winopen() create a new process ? 
> How can I
> solve that problem ? or did I miss something in the manuals ?
> 
> Thanks.
> 
> -- Alwin Dieperink
> 
> E-Mail : DIEPERINK@ULIIS.UNIL.CH
>          DIEPERINK@ELMA.EPFL.CH
>          ADIEPERI@CLSUNI51.BITNET
> 

The winopen forks off a process just so the program won't steal the shell.
To keep winopen from forking the process, precede it with a call to 
'foreground()'.

thant@sgi.com