How to stop a root exe program (compiled out side root)

Hi All,

I compile a program which uses root outside root.
I use this TApplication class to run it.

In my int main(…) at the end it says:
theApp.Run();
return(0);

the problem is that I want to start more of these executables one after the other in a script.
BUT: the first one never stops I always have to kill the exe with ctrl-c.

How do I tell theApp to quit when return 0 is reached??

Thanks
Andi

Hi Andi,

I am sure to grasp exactly what you want to do.
If you want to execute in batch a CINT script and return, use a TRint
instead of a TApplication and run your job with
myapp -b -q script.C
Otherwise, you can specify the argument kTRUE when calling
TApplication run as illustrated in the ROOT test program hworld2.cxx also
in the attachement

Rene
hworld2.cxx (1.17 KB)

Hi Rene,

hmm I tried with kTrue but it does not do what i want.

Here is what I want:

I compile a C++ file outside of root and cint. I get an executable.
Inside I have

int main(int argc, char **argv)
{
TApplication theApp(“App”, &argc, argv);
/// some event loop on an ntuple
theApp.Run();
return 0;
}

If I start that program in my shell it runs but it does not stop anymore.

I have to press CTRL-C in my shell to stop it. I need it to stop because a script starts it again with other input … kTrue did not help here.
Since I do not always need graphics (plot histos) a TApplication is probably the wrong thing to use here?

Cheers
Andi

Sorry I think I had some conceptual misunderstanding here.

TApplication is not needed just because I use root stuff in my code.
If I do not use graphics it works fine without it.

With graphics and TApplication it does of course not make too much sense to automatically end the application (the user wants to look at the graphics and closes the application by him/herself).

Cheers
Andi

OK you found out yourself.

Rene