Re: [ROOT] GTK+ GUI and Root interface

From: Brett Viren (bv@bnl.gov)
Date: Wed Feb 25 2004 - 00:02:34 MET


Hi Dejan,

Dejan Nikic writes:
 > SITUATION:  I have a GTK+ gui application that I wrote, and what it does
 > is gets some user input and creates a root macro file out of it and it
 > starts root and runs that macro using execlp() function.  
 > 
 > PROBLEM:  Every time I start root it closes my application and root runs
 > by itself just fine.  What I want to do is have root run and then I pass
 > it the user input from GTK, without having to start root every time and
 > have root close my application.
 > 

I think what you are missing is a "fork".  The exec family of
functions replaces the current executable with the new one.

Assuming you need to do any on going communication with root you can
set up a pair of pipes connected to root's stdin/stdout.  Keep reading
root's stdout file descriptor until you see the "root [xx]" prompt,
then print a new command to its stdin.

If you don't care about talking with the root subprocess at all, then
it is even easier to use the system() function to just spawn it off in
the background and forget about it.

Also, you might want to exec "root.exe" instead of "root".  The root
program proper just does some small things that doesn't need the full
set of libs.  For example, it handles any command line options asking
for help and throws up the splash screen.  It then turns around and
then exec's "root.exe" for all the real work.

-Brett.



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET