problem about gdk_input_add()
- From: "gaof" <gaof guoguang com cn>
- To: <gtk-app-devel-list gnome org>
- Subject: problem about gdk_input_add()
- Date: Fri, 21 Oct 2005 11:18:45 +0800
My dear friends,
I want to redirect the ouput of a shell command(ping) to a gtk widget(text).
I use FIFO, the code is something like this:
void
on_my_ping_show (GtkWidget *widget,
gpointer user_data)
{
int fd;
fd = open("/root/fifo", O_RDONLY | O_NONBLOCK);
gdk_input_add(fd, GDK_INPUT_READ, func, NULL);
}
void
on_button4_clicked (GtkButton *button,
gpointer user_data)
{
int pid;
pid = fork();
if (pid == 0) {
system("ping -c 4 192.168.3.3 > /root/fifo");
_exit(0);
}
}
static void
func(gpointer data, gint fd, GdkInputCondition conditon)
{
fprintf(stderr, "func####################\n");
}
When I click "button4", the function of "func" is not called immediately but waits until the function of
"system" returns.
Why?
Thanks!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]