Skip to content

Instantly share code, notes, and snippets.

@mohan43u
Created August 2, 2015 05:22
#!/usr/bin/env gjs
const GLib = imports.gi.GLib;
[ok, child_pid, standard_input, standard_output, standard_error] = GLib.spawn_async_with_pipes(null, ['cat'], null, GLib.SpawnFlags.SEARCH_PATH, null);
print("ok: " + ok);
print("child_pid: " + child_pid);
print("standard_input: " + standard_input);
print("standard_output: " + standard_output);
print("standard_error: " + standard_error);
let stdin = GLib.IOChannel.unix_new(standard_input);
let stdout = GLib.IOChannel.unix_new(standard_output);
let stderr = GLib.IOChannel.unix_new(standard_error);
[iostatus, bytes_written] = stdin.write_chars("helloworld\n", 11);
print("iostatus: " + (iostatus | GLib.IOStatus.NORMAL ? "success" : "failure"));
print("bytes_written: " + bytes_written);
stdin.flush();
[return_value, str_return, length, terminator_pos] = stdout.read_line();
print("return_value: " + (return_value | GLib.IOStatus.NORMAL ? "success" : "failure"));
print("str_return: " + str_return.trim());
print("length: " + length);
print("terminator_pos: " + terminator_pos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment