1 jls.loader.provide('jls.lang.Process'); 2 3 jls.lang.Process = jls.lang.Class.create( /** @lends jls.lang.Process.prototype */ 4 { 5 /** 6 * Creates a process with the specified command and arguments with the specified environment and working directory. 7 * 8 * @param {Array} cmdArray Array of strings specifying the command-line arguments. The first argument is the name of the executable file. 9 * @param {Array} envp Array of key-values specifying the environment strings. If undefined, the new process inherits the environment of the parent process. 10 * @param {jls.io.File} dir The working directory of the subprocess, or undefined if the subprocess should inherit the working directory of the current process. 11 * @constructs 12 * @class The class Process provides methods for performing input from the process, 13 * performing output to the process, waiting for the process to complete, 14 * checking the exit status of the process, and destroying (killing) the process. 15 */ 16 initialize : function(cmdArray, envp, processAttr) { 17 var cmd = (typeof cmdArray == 'string') ? [cmdArray] : cmdArray; 18 this._no = new _native.core.Process(cmd[0], cmd, envp, processAttr); 19 }, 20 /** 21 * Kills this process. 22 */ 23 destroy : function() { 24 this._no.kill(); 25 }, 26 /** 27 * Detach this process. 28 */ 29 detach : function() { 30 this._no.detach(); 31 }, 32 /** 33 * Wait for this process to terminate and return the exit value. 34 */ 35 waitFor : function() { 36 return this._no.wait(); 37 } 38 }); 39