how to read from UnixInputStream



I'm tring to spawn a command and read its output. In the sync way, I
find imports.gi.GLib.spawn_command_line_sync is fine. But in the async
way, I cannot find any information on dealing with the unix file
descriptor.

try the code below:

glib = imports.gi.GLib;
cmd = 'uname -a';
[success,argc,argv] = glib.shell_parse_argv(cmd);
[success,pid,stdin,stdout,stderr] =
glib.spawn_async_with_pipes(null,argv,null,glib.SpawnFlags.SEARCH_PATH,null,null);
gio = imports.gi.Gio;
stream = new gio.UnixInputStream({fd:stdout});

we can get a UnixInputStream, but I don't know how to use the read
method. The g_input_stream_read indicates that there should be 3
parameters, a buffer(void*), a count(gsize), a cancellable
object(GCancellable). Then, what's the corressponding type for void* in
gjs?



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