Problems with window id after fork()

Hello,
I have following problem.

I have created a main window and subwindow and can speak to them with glutsetwindow(main) or glutsetwindow(sub).
But after doing a fork, where my child process open another program, I want to let my father process working with my opengl windows, he can’t find the id’s of my both windows.
Following error messages appear:
Freeglut: in glutsetwindow(), window id not found.

If it is important for that i am working on a Linux system.

Have anyone an idea, what’s going wrong?

Thank’s a lot,

Christoph

it would help if you posted a snippet of your code. it’s hard to pinpoint the problem based simply on your description.

:regards:

I am almost positive that you are uncertain as to
which process is the father and which process is the
child! I believe that you are fork()ing with a call
like this:

if(fork()) {

What happens is the father process does the work of
the child and the child is left with the windows.
Really, the roles are reversed. But you are lucky!
Simply change the fork()ing call to look like thos:

if(!fork()) {

so that the roles of parent and child are now
interchanged. It should reverse the behaviour and
the problem should be solved.

And of course, I could be dead wrong too…

Thank’s for your answers.

To iznogoud:
I have already tried to change father and child, but it is still worse.

The code:

//An event in OpenGL starts this function:

void start_calculation(void)
{
int proc;
proc = fork();
if (proc > 0) //father
{
// do sth. what is not interesting for my problem

}
else if (proc == 0)	//child
{
	/* Open program CCLSD */
	system("./CCLSD 22");
	exit(0);
}

}

//After this function I will go to my idle function:

void idle(void)
{
static one = 0;
/* Update state variables */
spin += SMALL_ANGLE;
time += TIME_STEP;

if (start == 1)
{
	/* starting the calculation */
	//start = 0;
	if (one == 0)
	{
		start_calculation();
		one = 1;
	}
}	

/* Update main and sub window */
glutSetWindow (winIdMain);
glutPostRedisplay ();
glutSetWindow (winIdSub);
glutPostRedisplay ();

}

/* And after I run the function start_calculation, glutSetWindow(winIdMain) can’t find the id of winIdMain. winIdMain is a global variable*/

I hope the code will help you, to solve my problem.

Christoph

Perhaps still sth. interesting.

Before I want to set the MainWindow the active window with: glutSetWindow (winIdMain);
I ask for the active window with glutGetWindow() and get the answer 0. Does it mean, there is no active window at the moment? I still wonder that my subwindow is still available, it’s only my main window what’s running wrong.

Thank’s a lot for your help.

Christoph

Hello all,

had found my problem, had nothing to do with glut or multi-processing, only a damned mistake with memory allocation and reading from a pipe.

Thank’s for your help.

Good night,

Christoph

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.