summaryrefslogtreecommitdiff
path: root/shell/samples/os.fork.js
diff options
context:
space:
mode:
Diffstat (limited to 'shell/samples/os.fork.js')
-rw-r--r--shell/samples/os.fork.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/shell/samples/os.fork.js b/shell/samples/os.fork.js
new file mode 100644
index 00000000..debdebcc
--- /dev/null
+++ b/shell/samples/os.fork.js
@@ -0,0 +1,30 @@
+igt.os.fork('hello', print).wait();
+
+igt.os.fork([ {delay: 1, msg:'goodbye' }, {delay:0, msg:'world'} ],
+ function(x) { igt.os.sleep(x.delay); print(x.msg) }).wait();
+
+var job = igt.os.fork('', function(x) { igt.os.exit(1); igt.os.sleep(999); });
+print('Exitcode = ' + job.wait());
+
+job = igt.os.fork();
+if (job) {
+ print("Parent shall wait for its child!");
+ job.wait();
+} else {
+ print("The child wants to play!");
+ for (var x = 0; x < 10; x++) {
+ print("Play " + x);
+ igt.os.sleep(0.1);
+ }
+ print("Tired now!");
+ igt.os.exit(0);
+}
+print("Only parents allowed after children sleep, exitcode:", job.result);
+
+job = igt.os.fork();
+if (job) {
+ print("No Mr Bond, I expect you to", job.wait());
+} else {
+ badwolf();
+}
+print("Onwards, all by myself.");