Recovering msgs from system() or fork() with Gtk+



Hi,

I want to be able to start any command / application that could be given
by the user from a gtk+ application:

(1)    The task must be independant from parent gtk+ app, so that the
user can continue the use the parent;

(2)    I want to recover the error message, when the user gives a not
executable string, so that I can display it in a Gtk window.

Suppose the application is a simple text editor.  Something could be
done this way:

system("gedit mytext &");

Suppose now that the user makes a typo and gives "gedti".  Because
"system" launches a shell, the execution is successful (given the shell
is working).  It seems there is no way to recover the result of the
command inside the shell.  The only way for the user to know there was a
problem is to start the parent from an X console, where the child
displays its error message.

I tried to use fork() followed by execlp()/execvp() in the child
process.  Fork() works when the child process exits with  _exit()
instead of exit().  Unfortunately, it doesn't work when I put a Gtk call
in the child process for displaying the error message.  The message
window displays, but hangs.  I've seen a message in this mailing list
saying it is not supposed to work.  I don't know the details.

Does somebody knows an elegant way to do the job?  For now, the called
application can be a text editor or a renderer like povray.

Thanks!

Patrice St-Gelais










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