Re: Call external programs and keep showing its outputs

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

 



On Thu, Oct 10, 2013 at 07:35:09PM +0800, Kang Hu wrote:
> see
> https://developer.gnome.org/glib/2.38/glib-Spawning-Processes.html#g-spawn-async-with-pipes
> 1. call g_spawn_async_with_pipes and get the stdin, stdout, stderr fds.
> 2. call g_child_watch on the pid returned in step 1.
> 3. create an io channel for each fd ( see g_io_channel_unix_new)
> 4. add each io channel to the main loop ( see g_io_add_watch) .
>    read external  application output (see g_io_channel_read_*)  in the
> callback function GIOFunc
>    and update your widget's text section
> 5. you can kill external programs by the pid you get in step 1.
> NOTE: you need to release fds in callbacks in step 2.
> 
> 
The answer is wanderful!  Thank you Kang Hu!

> On Thu, Oct 10, 2013 at 12:55 PM, Woody Wu <narkewoody@xxxxxxxxx> wrote:
> 
> > Hi,
> >
> > I am about to write a test runner with GTK+. It basically can list a lot
> > of external test programs (non-GTK+ pure Linux apps) in a treeview and
> > let user select one of them to run. While an external program is
> > running, I want to get all its outputs (to stdout/stderr) and keep
> > updating in a textview.
> >
> > Since I am a Linux programmer, so I know how to fork a new process and
> > pipe into an external program. But I don't know in GTK+, what's the
> > right method to keep fetching the information from the pipe and showing
> > them in my GUI widgets.  On the other hand, while an external program is
> > running, I don't want user feel that the my program is frozing and user
> > should be able to kill the running external program by clicking a 'stop'
> > button on the GUI.
> >
> > For this kind of task, what GTK+ technology I should go to grab?  Thanks
> > in advance!
> >
> > --
> > I can't go back to yesterday - because I was a different person then
> > _______________________________________________
> > gtk-list mailing list
> > gtk-list@xxxxxxxxx
> > https://mail.gnome.org/mailman/listinfo/gtk-list
> >

-- 
I can't go back to yesterday - because I was a different person then
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux