Thread on a static method

Hi,
i would like to run a process in a thread meanwhile another one is listening on the standard out.
Actually my guiApplication

  1. use the “system(char*)” C function to start a stand alone program;
  2. write the standard output on a file
  3. then read the file and put that text in a TGTextEdit window.
    In near future i’d like to avoid that system() call and integrate bettere the two codes anyway…
    I would like to make this in a realtime-like way starting the standalone program in a thread and then (just to begin) redirect the standard output as i do now. The problem is that i always got a “segmentation fault”.
    The sequence of code (just the relevant parts) is below

fLogFile=freopen(logfile, “w”, stdout))
TThread provaThread = new TThread(“provaTThread”, (void() (void*))ExecuteCmd::execute);
provaThread->Run();
TGTextView *t = new TGTextView(gClient->GetRoot(),800,200);
t->MapSubwindows();
t->MapWindow();
fgets(string,120,fLogFile);
while (!feof(fLogFile)) {
fflush(fLogFile);
t->AddLine(string);
fgets(string,120,fLogFile);
}
fclose(fLogFile);
}

the static method called in the thread is simply

void ExecuteCmd::execute(string cmd = “”, string parameters = “”){
int i = system(“yoda /home/kusanagi/Data/YodaData/040406_1.dat”);
}

the standard output is correctly redirected and the TextView also correctly open but into i found only one line

“Segmentation fault”

Any suggestion?
Thanks
Maurizio

Hi,

From your descripition I assume that the segmentation fault comes from your yoda software. This can be due to many things. Hopefully your system is configure to keep ‘core file’ around and your might gain some information by just starting gdb with something like

Cheers,
Philippe.