Module | Process |
In: |
lib/win32/process.rb
|
WIN32_PROCESS_VERSION | = | '0.5.3' | ||
ProcessInfo | = | Struct.new("ProcessInfo", :process_handle, :thread_handle, :process_id, :thread_id | Used by Process.create |
Process.create(key => value, …) => ProcessInfo
This is a wrapper for the CreateProcess() function. It executes a process, returning a ProcessInfo struct. It accepts a hash as an argument. There are six primary keys:
Of these, the ‘app_name’ must be specified or an error is raised.
The startup_info key takes a hash. Its keys are attributes that are part of the StartupInfo struct, and are generally only meaningful for GUI or console processes. See the documentation on CreateProcess() and the StartupInfo struct on MSDN for more information.
The relevant constants for ‘creation_flags’, ‘sw_flags’ and ‘startf_flags’ are included in the Windows::Process, Windows::Console and Windows::Window modules. These come with the windows-pr package, a prerequisite of this package. Note that the ‘stdin’, ‘stdout’ and ‘stderr’ options can be either Ruby IO objects or file descriptors (i.e. a fileno). However, StringIO objects are not currently supported.
The ProcessInfo struct contains the following members:
Creates the equivalent of a subshell via the CreateProcess() function. This behaves in a manner that is similar, but not identical to, the Kernel.fork method for Unix.
Sends the given signal to an array of process id‘s. The signal may be any value from 0 to 9, or the special strings ‘SIGINT’ (or ‘INT’), ‘SIGBRK’ (or ‘BRK’) and ‘SIGKILL’ (or ‘KILL’). An array of successfully killed pids is returned.
Signal 0 merely tests if the process is running without killing it. Signal 2 sends a CTRL_C_EVENT to the process. Signal 3 sends a CTRL_BRK_EVENT to the process. Signal 9 kills the process in a harsh manner. Signals 1 and 4-8 kill the process in a nice manner.
SIGINT/INT corresponds to signal 2 SIGBRK/BRK corresponds to signal 3 SIGKILL/KILL corresponds to signal 9
Signals 2 and 3 only affect console processes, and then only if the process was created with the CREATE_NEW_PROCESS_GROUP flag.
Waits for any child process to exit and returns the process id of that child.
Note that the $? (Process::Status) global variable is NOT set. This may be addressed in a future release.
Waits for any child process to exit and returns an array containing the process id and the exit status of that child.
Note that the $? (Process::Status) global variable is NOT set. This may be addressed in a future release.
Waits for the given child process to exit and returns that pid.
Note that the $? (Process::Status) global variable is NOT set. This may be addressed in a future release.