File: bi.js

package info (click to toggle)
seed 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,900 kB
  • sloc: ansic: 24,336; sh: 11,196; makefile: 773; xml: 187; python: 173
file content (28 lines) | stat: -rwxr-xr-x 561 bytes parent folder | download | duplicates (4)
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);