1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/usr/bin/env seed
multiprocessing = imports.multiprocessing;
Gtk = imports.gi.Gtk;
os = imports.os;
JSON = imports.JSON;
pipes = new multiprocessing.Pipe();
child_pid = os.fork();
if (child_pid == 0)
{
mine = pipes[0];
mine.add_watch(1,
function()
{
var message = {type: "PING",
data: "Hello!"};
mine.write(JSON.stringify(message));
return true;
});
Gtk.main();
}
mine = pipes[1];
mine.write("Ping");
message = JSON.parse(mine.read());
print("Parent Got: " + message.type + ": " + message.data);
|