GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] g_timeout_add runs function only once

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Zarg
Familiar Face


Joined: 09 Mar 2008
Posts: 10

PostPosted: Tue Apr 01, 2008 9:00 pm    Post subject: [SOLVED] g_timeout_add runs function only once Reply with quote

Hello everybody!

I use g_timeout_add to run the following code once per second:

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
void update (void)
{
    FILE *output;
    // char temp[100];
   
output = popen("ls", "r");
    // save output to temp char
   
pclose(output);
   
    g_print ("Hello World\n");
   
    return;
}

This will (of course) print useless "Hello World"s to the command line ...
The problem is that if I uncomment line 4 I'll only get one "Hello World"! It seems that the code only gets executed once ... what's the problem with chars and g_timeout_add?

Thank you for your help!


Last edited by Zarg on Wed Apr 02, 2008 5:47 am; edited 1 time in total
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 37

PostPosted: Wed Apr 02, 2008 4:02 am    Post subject: Reply with quote

update() function must be gboolean. It should return TRUE if timeout loop must be repeated. And your function returns random value that depends on register eax (on i8086) value.
Back to top
Zarg
Familiar Face


Joined: 09 Mar 2008
Posts: 10

PostPosted: Wed Apr 02, 2008 5:47 am    Post subject: Reply with quote

Thank you!

That really helped! :)

But it's really strange that it always worked without the char declaration and never worked with it ... anyway, problem solved! :)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP