gdk_input_*, events, refresh, etc ( help )

Hi to everybody,

some time ago I posted a question regarding how to capture the file
descriptor of a program forked by a GTK application ( the backend of a
simulator that I'm writing ). Somebody pointed me to the function
gdk_input_add(), which allowed me to do that ( thnks to everybody who
anwered ). 
Then, I had the problem that I wanted to give interactivity to the
frontend, while the simulation is running ( I'm plotting the results
captured from the backend and doing some other stuff ). So, following
the suggestion of another kind developer, I added basically the
following in the callback of the gdk_input_add():

void input_callback( gpointer data, gint source,GdkInputCondition
condition )
    char    buffer[1024];

    while (fgets(buffer, sizeof(buffer), errfile )
       parse_output_simul( buffer );
       while (gtk_events_pending())

The problem is that the simulation run for a long time, and if I decide
to stop the backend with the following lines called when pressing a
button, my frontend dies.

    gdk_input_remove( input_id );

    kill( simpid, 9 );
    simpid = 0;
    wait( &simpid );

    fclose( errfile );

Running GDB on the core file founds that I'm running out of stack. I
blame it to the while(gtk_events_pending() ) and the call to
gtk_main_iteration in my callback, so I rewrote the callback function to 

if (fgets(buffer, sizeof(buffer), errfile))
   parse_output_simul( buffer );

which is a lot simpler and doesn't core anymore. I replace the
while(fgets) cause due to the high rate of the backend, sometimes there
were too many data in the file buffer and the application wasn't getting
out of the callback. The problem right now is that the screen is not
refreshed very well anymore, and the application is somewhat
unresponsive ( I'm even having some problems with some timers that are
periodically refreshing the graph plotting ).

Could somebody send me the magic recipe to how to make the events to be
processed and still not running out of stack space ? The out of stack
space only happens after a somehow long simulation ( several minutes ).
I can give more information if needed.

Thanks in advance


Hugo Varotto
Computer Science Dept.
University of Pittsburgh

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]