Re: Arrays, Returns and Fork



On  5 Mar, Steve & Patti Getzinger wrote:
Here is what I have. I immediately fork to run one func that shows a
splash and while that is running a second func (in child) to run a
locate command and create an array of the returns. I then am killing the
child process. I need the array from the child in the next function that
executes in the parent. Is there a wiser way to build this array? The
locate command stalls the main app if not forked (naturally). I need the
array to build labels for radio buttons in the dialog that comes up
after the splash. Any thoughts?

Use popen(3), and parse it's output by adding a watch on an io_channel that
you connect to the file decriptor that's part of the FILE* that popen
returns:

FILE *f;
GIOChannel *c;
gboolean func (GIOChannel *source, GIOCondition condition, gpointer data);

f = popen ("locate foo", "r");
c = g_io_channel_unix_new (fileno(f);
g_io_add_watch (c, G_IO_IN, &func, 0);


Roland
-- 
Roland Smith                        "When life hands you a lemon,
r s m i t h @ x s 4 a l l . n l      make lemonade."
http://www.xs4all.nl/~rsmith/

Attachment: pgpYjZk6JjPMh.pgp
Description: PGP signature



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