g_spawn question



Hi,

I have a question regarding the g_spawn functions in glib.  I'm writing an 
infra-red panel application using gnome2 libraries.

One of the things this app does is execute external helper shell scripts.  
These scripts output minimized information while they're running.  This 
output should then be captured by the panel app and displayed line by 
line.

Now, what I did was use g_spawn_async_with_pipes and connect a GIOChannel 
to the stdout of the spawned process.  This works; I can process the 
output of the spawned process line by line.

The problem starts when the spawned process is done running.  For some 
reason my app starts spinning idly, using 99.9% CPU.

Now, my suspicion is that when the spawned process stops, the 
corresponding iochannel of stdout isn't unreffed.  I'm not sure if this is 
the case or how to verify this; I can only tell from what I see and from 
my (maybe mistaken) interpretation of the glib source code.  But I suppose 
it might be likely that, for example, the file descriptor of the spawned 
stdout is closed, but the iochannel doesn't know.

So, my question is, does this make sense ? Is this the right behaviour ? 
Is there some way I can install a callback to be called when the spawned 
process stops ? How can I cleanly prevent my app from spinning idly, or 
otherwise debug the situation ?

Thanks in advance,
Thomas

-- 

The Dave/Dina Project : future TV today ! - http://davedina.apestaart.org/
<-*-                      -*->
Cause I wake to find there's
nothing left of me in her
nothing more than a heart still at war
<-*- thomas apestaart org -*->





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