os.js (1440B)
1 // |reftest| skip-if(!xulRuntime.shell||winWidget) 2 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 3 /* 4 * Any copyright is dedicated to the Public Domain. 5 * http://creativecommons.org/licenses/publicdomain/ 6 */ 7 8 var pid = os.getpid(); 9 assertEq(pid > 0, true); 10 11 var PATH = os.getenv("PATH"); 12 assertEq(PATH.indexOf("bin") > 0, true); 13 assertEq(os.getenv("SQUAMMISH_HILLBILLY_GOAT_SQUEEZERS"), undefined); 14 15 assertEq(os.system("true"), 0, "/bin/true should exit 0"); 16 assertEq(os.system("false") != 0, true, "/bin/false should exit nonzero"); 17 18 var kidpid = os.spawn("sleep 60"); 19 assertEq(kidpid > 0, true, "spawning sleep"); 20 var info = os.waitpid(kidpid, true); 21 assertEq(info.hasOwnProperty("pid"), false); 22 assertEq(info.hasOwnProperty("exitStatus"), false); 23 24 os.kill(kidpid); 25 26 info = os.waitpid(kidpid); 27 assertEq(info.hasOwnProperty("pid"), true, "waiting on dead process should return pid"); 28 assertEq(info.pid, kidpid); 29 assertEq(info.hasOwnProperty("exitStatus"), false, "killed process should not have exitStatus"); 30 31 kidpid = os.spawn("false"); 32 assertEq(kidpid > 0, true, "spawning /bin/false"); 33 info = os.waitpid(kidpid); 34 assertEq(info.hasOwnProperty("pid"), true, "waiting on dead process should return pid"); 35 assertEq(info.pid, kidpid); 36 assertEq(info.hasOwnProperty("exitStatus"), true, "process should have exitStatus"); 37 assertEq(info.exitStatus, 1, "/bin/false should exit 1"); 38 39 reportCompare(true, true);