[Glade-users] newbie: making system calls from GUI

Tomi Manninen OH2BNS tpm@prkele.tky.hut.fi
Thu, 6 Feb 2003 17:40:17 +0200 (EET)


On Thu, 6 Feb 2003, Joachim Backes wrote:

> On 06-Feb-2003 Manu C S wrote: 
> >  
> >  For example, if I want to launch a browser from my gui
> >  when a user clicks on a certain button, should I have this in
> >  the callback function of that button:
> >      system("mozilla");
> >  Is that correct?
> >  How do I handle commands that write to stdout?
> 
> Use the "popen()" system call.

For whatever reason, when I ported my application to Gnome2/GTK2 this
stopped working. I needed to (synchronously) run a simple program and read
its stdout to a buffer. For some reason this started to fail sporadicly
with "interrupted system call" messages...

So, I dug up the API documents and the GLib helper function g_spawn_sync()
was just what I needed...

See:

 http://developer.gnome.org/doc/API/2.0/glib/glib-Spawning-Processes.html

-- 
Tomi Manninen           Internet:  oh2bns@sral.fi
OH2BNS                  AX.25:     oh2bns@oh2rbi.fin.eu
KP20ME04                Amprnet:   oh2bns@oh2rbi.ampr.org