diff options
Diffstat (limited to 'modules/multiprocessing/bi.js')
-rwxr-xr-x | modules/multiprocessing/bi.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/multiprocessing/bi.js b/modules/multiprocessing/bi.js new file mode 100755 index 0000000..a90c3d1 --- /dev/null +++ b/modules/multiprocessing/bi.js @@ -0,0 +1,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); |