win32-process 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,180 +1,189 @@
1
- = 0.6.2 - 19-Dec-2009
2
- * Fixed an issue where stdin, stdout and stderr might not be inheritable
3
- even if the inherit option was set. Thanks go to Michael Buselli for the
4
- spot and the patch.
5
- * Added a basic implementation of Process.getrlimit.
6
- * Added the Process.get_affinity method.
7
- * Added test-unit 2.x and sys-proctable as development dependencies.
8
- * Added the :uninstall and :build_gem Rake tasks to the Rakefile.
9
- * Bumped required version of windows-pr to 1.0.6.
10
-
11
- = 0.6.1 - 16-Jul-2009
12
- * Added the Process.uid method. This method returns a user id (really, the RID
13
- of the SID) by default, but can also take an optional parameter to return
14
- a binary SID instead at the user's discretion.
15
- * Added working implementations of Process.getpriority and Process.setpriority.
16
- Note they they only work for processes, not process groups or users.
17
- * Set license to Artistic 2.0, and updated the gemspec.
18
-
19
- = 0.6.0 - 31-Oct-2008
20
- * The mandatory argument for Process.create has been switched from 'app_name'
21
- to 'command_line', to be more in line with underlying CreateProcess API.
22
- Note that 'command_line' will default to 'app_name' if only the latter is
23
- set, but both may be set individually. Keep in mind that 'app_name' must
24
- be a full path to the executable. Thanks go to Jeremy Bopp for the patch.
25
- * Removed the deprecated ProcessError constant. Use Process::Error instead.
26
- * Explicitly include and extend the Windows::Thread module now. Thanks go to
27
- Qi Lu for the spot.
28
- * Slightly more robust internal code handling for some of the other methods,
29
- typically related to ensuring that HANDLE's are closed.
30
- * Example programs are now included with the gem.
31
-
32
- = 0.5.9 - 14-Jun-2008
33
- * Added a proper implementation of Process.ppid.
34
-
35
- = 0.5.8 - 24-Mar-2008
36
- * Fixed a bug in Process.create where the handles in the PROCESS_INFORMATION
37
- struct were not closed, regardless of the 'close_handles' option. Thanks
38
- go to Lars Christensen for the spot and the patch.
39
-
40
- = 0.5.7 - 27-Mar-2008
41
- * Fixed issues with thread_inherit and process_inherit in the Process.create
42
- method. This in turn required an update to windows-pr. Thanks go to Steve
43
- Shreeve for the spot.
44
- * Fixed a potential issue with startf_flags and stdin/stdout/stderr handling.
45
- Thanks again go to Steve Shreeve for the spot and the patch.
46
- * Fixed the code so that it no longer emits redefinition warnings.
47
- * Fixed a bug in the Rake install task (for non-gem installations).
48
-
49
- == 0.5.6 - 13-Mar-2008
50
- * Fixed a bug in the Process.waitpid2 method where it wasn't returning the
51
- proper exit code. Thanks go to Jeremy Bopp for the spot and the patch.
52
- * In the spirit of DWIM, if the 'stdin', 'stdout' or 'stderr' keys are
53
- encountered in the startup_info hash, then the inherit flag is automatically
54
- set to true and the startf_flags key is automatically OR'd with the
55
- STARTF_USESTDHANDLES value. Thanks go to Sander Pool for the inspiration.
56
-
57
- == 0.5.5 - 12-Dec-2007
58
- * The Process.create method now automatically closes the process and thread
59
- handles in the ProcessInfo struct before returning, unless you explicitly
60
- tell it not to via the 'close_handles' option.
61
- * The Process.create method now supports creating a process as another user
62
- via the 'with_logon', 'password' and 'domain' options.
63
-
64
- == 0.5.4 - 23-Nov-2007
65
- * Changed ProcessError to Process::Error.
66
- * Now requires windows-pr 0.7.3 or later because of some reorganization in
67
- that library with regards to thread functions.
68
- * Better cleanup of HANDLE's in a couple methods when failure occurs.
69
- * Added an additional require/include necessitated by a change in the method
70
- organization in the windows-pr library.
71
-
72
- == 0.5.3 - 29-Jul-2007
73
- * Added a Rakefile with tasks for installation and testing.
74
- * Removed the install.rb file (now handled by the Rakefile).
75
- * Updated the README and MANIFEST files.
76
-
77
- == 0.5.2 - 22-Jan-2007
78
- * The startup_info parameter for the Process.create method now accepts
79
- 'stdin', 'stdout', and 'stderr' as valid parameters, which you can pass
80
- a Ruby IO object or a fileno in order to redirect output from the created
81
- process.
82
-
83
- == 0.5.1 - 24-Aug-2006
84
- * Fixed a bug in the Process.create method where the return value for
85
- CreateProcess() was being evaluated incorrectly. Thanks go to David Haney
86
- for the spot.
87
- * Added a slightly nicer error message if an invalid value is passed to the
88
- Process.create method.
89
- * Removed an extraneous '%' character from an error message.
90
-
91
- == 0.5.0 - 29-Jul-2006
92
- * The Process.create method now returns a ProcessInfo struct instead of the
93
- pid. Note that you can still grab the pid out of the struct if needed.
94
- * The Process.create method now allows the process_inherit and
95
- thread_inherit options which determine whether a process or thread
96
- object's handles are inheritable, respectively.
97
- * The wait and wait2 methods will now work if GetProcessId() isn't defined
98
- on your system.
99
- * The 'inherit?' hash option was changed to just 'inherit' (no question mark).
100
- * Minor doc correction - the 'inherit' option defaults to false, not true.
101
-
102
- == 0.4.2 - 29-May-2006
103
- * Fixed a typo/bug in Process.kill for signal 3, where I had accidentally
104
- used CTRL_BRK_EVENT instead of the correct CTRL_BREAK_EVENT. Thanks go
105
- to Luis Lavena for the spot.
106
-
107
- == 0.4.1 - 13-May-2006
108
- * Fixed a bug where spaces in $LOAD_PATH would cause Process.fork to fail.
109
- Thanks go to Justin Bailey for the spot and patch.
110
- * Added a short synopsis to the README file.
111
-
112
- == 0.4.0 - 7-May-2006
113
- * Now pure Ruby, courtesy of the Win32API package.
114
- * Now comes with a gem.
115
- * Modified Process.kill to send a signal to the current process if pid 0
116
- is specified, as per the current 1.8 behavior.
117
- * Process.create now accepts the 'environment' key/value, where you can
118
- pass a semicolon-separated string as the environment for the new process.
119
- * Moved the GUI related options of Process.create to subkeys of the
120
- 'startup_info' key. See documentation for details.
121
- * Replaced Win32::ProcessError with just ProcessError.
122
-
123
- == 0.3.3 - 16-Apr-2006
124
- * Fixed a bug in Process.create with regards to creation_flags. Thanks go
125
- to Tophe Vigny for the spot.
126
-
127
- == 0.3.2 - 12-Aug-2005
128
- * Fixed a bug in Process.kill where a segfault could occur. Thanks go to
129
- Bill Atkins for the spot.
130
- * Changed VERSION to WIN32_PROCESS_VERSION, because it's a module.
131
- * Made the CHANGES, README and doc/process.txt documents rdoc friendly.
132
- * Removed the process.rd file.
133
-
134
- == 0.3.1 - 9-Dec-2004
135
- * Modified Process.fork to return an actual PID instead of a handle. This
136
- means that it should work with Process.kill and other methods that expect
137
- an actual PID.
138
- * Modified Process.kill to understand the strings "SIGINT", "INT", "SIGBRK",
139
- "BRK", "SIGKILL" and "KILL". These correspond to signals 2, 3 and 9,
140
- respectively.
141
- * Added better $LOAD_PATH handling for Process.fork. Thanks go to Aslak
142
- Hellesoy for the spot and the patch.
143
- * Replaced all instances of rb_sys_fail(0) with rb_raise(). This is because
144
- of a strange bug in the Windows Installer that hasn't been nailed down yet.
145
- This means that you can't rescue Errno::ENOENT any more, but will have to
146
- rescue StandardError. This only affects Process.kill.
147
- * The signals that were formerly 1 and 2 and now 2 and 3. I did this because
148
- I wanted the same signal number for SIGINT as it is on *nix.
149
- * Added a test_kill.rb script under the examples directory.
150
- * Other minor cleanup and corrections.
151
-
152
- == 0.3.0 - 25-Jul-2004
153
- * Added the create() method.
154
- * Moved the example programs to doc/examples.
155
- * Updated the docs, and toned down claims of fork's similarity to the Unix
156
- version.
157
- * Minor updates to the test suite.
158
-
159
- == 0.2.1 - 17-May-2004
160
- * Made all methods module functions, except fork, rather than singleton
161
- methods.
162
- * Minor doc changes.
163
-
164
- == 0.2.0 - 11-May-2004
165
- * Removed the Win32 module/namespace. You no longer 'include Win32' and you
166
- no longer need to prefix Process with 'Win32::'.
167
- * The fork() method is now a global function as well as a method of the
168
- Process module. That means you can call 'fork' instead of 'Process.fork'
169
- if you like.
170
- * Doc updates to reflect the above changes.
171
-
172
- == 0.1.1 - 6-Mar-2004
173
- * Fixed bug where spaces in the directory name caused the fork() method to
174
- fail (Park).
175
- * Normalized tc_process.rb somewhat to make it easier to run outside of the
176
- test directory if desired.
177
- * Fixed up tc_process.rb a bit.
178
-
179
- == 0.1.0 - 19-Feb-2004
180
- * Initial release
1
+ = 0.6.3 - 9-Nov-2010
2
+ * Fixed a bug in the Process.kill method where the remote thread created
3
+ was not being properly closed. Thanks go to Ben Nagy for the spot.
4
+ * Added the Process.job? method that returns whether or not the current process
5
+ is already in a job.
6
+ * Added the Process.setrlimit method. Like the Process.getrlimit method it
7
+ only supports a limited subset of resources.
8
+ * Rakefile tweaks.
9
+
10
+ = 0.6.2 - 19-Dec-2009
11
+ * Fixed an issue where stdin, stdout and stderr might not be inheritable
12
+ even if the inherit option was set. Thanks go to Michael Buselli for the
13
+ spot and the patch.
14
+ * Added a basic implementation of Process.getrlimit.
15
+ * Added the Process.get_affinity method.
16
+ * Added test-unit 2.x and sys-proctable as development dependencies.
17
+ * Added the :uninstall and :build_gem Rake tasks to the Rakefile.
18
+ * Bumped required version of windows-pr to 1.0.6.
19
+
20
+ = 0.6.1 - 16-Jul-2009
21
+ * Added the Process.uid method. This method returns a user id (really, the RID
22
+ of the SID) by default, but can also take an optional parameter to return
23
+ a binary SID instead at the user's discretion.
24
+ * Added working implementations of Process.getpriority and Process.setpriority.
25
+ Note they they only work for processes, not process groups or users.
26
+ * Set license to Artistic 2.0, and updated the gemspec.
27
+
28
+ = 0.6.0 - 31-Oct-2008
29
+ * The mandatory argument for Process.create has been switched from 'app_name'
30
+ to 'command_line', to be more in line with underlying CreateProcess API.
31
+ Note that 'command_line' will default to 'app_name' if only the latter is
32
+ set, but both may be set individually. Keep in mind that 'app_name' must
33
+ be a full path to the executable. Thanks go to Jeremy Bopp for the patch.
34
+ * Removed the deprecated ProcessError constant. Use Process::Error instead.
35
+ * Explicitly include and extend the Windows::Thread module now. Thanks go to
36
+ Qi Lu for the spot.
37
+ * Slightly more robust internal code handling for some of the other methods,
38
+ typically related to ensuring that HANDLE's are closed.
39
+ * Example programs are now included with the gem.
40
+
41
+ = 0.5.9 - 14-Jun-2008
42
+ * Added a proper implementation of Process.ppid.
43
+
44
+ = 0.5.8 - 24-Mar-2008
45
+ * Fixed a bug in Process.create where the handles in the PROCESS_INFORMATION
46
+ struct were not closed, regardless of the 'close_handles' option. Thanks
47
+ go to Lars Christensen for the spot and the patch.
48
+
49
+ = 0.5.7 - 27-Mar-2008
50
+ * Fixed issues with thread_inherit and process_inherit in the Process.create
51
+ method. This in turn required an update to windows-pr. Thanks go to Steve
52
+ Shreeve for the spot.
53
+ * Fixed a potential issue with startf_flags and stdin/stdout/stderr handling.
54
+ Thanks again go to Steve Shreeve for the spot and the patch.
55
+ * Fixed the code so that it no longer emits redefinition warnings.
56
+ * Fixed a bug in the Rake install task (for non-gem installations).
57
+
58
+ == 0.5.6 - 13-Mar-2008
59
+ * Fixed a bug in the Process.waitpid2 method where it wasn't returning the
60
+ proper exit code. Thanks go to Jeremy Bopp for the spot and the patch.
61
+ * In the spirit of DWIM, if the 'stdin', 'stdout' or 'stderr' keys are
62
+ encountered in the startup_info hash, then the inherit flag is automatically
63
+ set to true and the startf_flags key is automatically OR'd with the
64
+ STARTF_USESTDHANDLES value. Thanks go to Sander Pool for the inspiration.
65
+
66
+ == 0.5.5 - 12-Dec-2007
67
+ * The Process.create method now automatically closes the process and thread
68
+ handles in the ProcessInfo struct before returning, unless you explicitly
69
+ tell it not to via the 'close_handles' option.
70
+ * The Process.create method now supports creating a process as another user
71
+ via the 'with_logon', 'password' and 'domain' options.
72
+
73
+ == 0.5.4 - 23-Nov-2007
74
+ * Changed ProcessError to Process::Error.
75
+ * Now requires windows-pr 0.7.3 or later because of some reorganization in
76
+ that library with regards to thread functions.
77
+ * Better cleanup of HANDLE's in a couple methods when failure occurs.
78
+ * Added an additional require/include necessitated by a change in the method
79
+ organization in the windows-pr library.
80
+
81
+ == 0.5.3 - 29-Jul-2007
82
+ * Added a Rakefile with tasks for installation and testing.
83
+ * Removed the install.rb file (now handled by the Rakefile).
84
+ * Updated the README and MANIFEST files.
85
+
86
+ == 0.5.2 - 22-Jan-2007
87
+ * The startup_info parameter for the Process.create method now accepts
88
+ 'stdin', 'stdout', and 'stderr' as valid parameters, which you can pass
89
+ a Ruby IO object or a fileno in order to redirect output from the created
90
+ process.
91
+
92
+ == 0.5.1 - 24-Aug-2006
93
+ * Fixed a bug in the Process.create method where the return value for
94
+ CreateProcess() was being evaluated incorrectly. Thanks go to David Haney
95
+ for the spot.
96
+ * Added a slightly nicer error message if an invalid value is passed to the
97
+ Process.create method.
98
+ * Removed an extraneous '%' character from an error message.
99
+
100
+ == 0.5.0 - 29-Jul-2006
101
+ * The Process.create method now returns a ProcessInfo struct instead of the
102
+ pid. Note that you can still grab the pid out of the struct if needed.
103
+ * The Process.create method now allows the process_inherit and
104
+ thread_inherit options which determine whether a process or thread
105
+ object's handles are inheritable, respectively.
106
+ * The wait and wait2 methods will now work if GetProcessId() isn't defined
107
+ on your system.
108
+ * The 'inherit?' hash option was changed to just 'inherit' (no question mark).
109
+ * Minor doc correction - the 'inherit' option defaults to false, not true.
110
+
111
+ == 0.4.2 - 29-May-2006
112
+ * Fixed a typo/bug in Process.kill for signal 3, where I had accidentally
113
+ used CTRL_BRK_EVENT instead of the correct CTRL_BREAK_EVENT. Thanks go
114
+ to Luis Lavena for the spot.
115
+
116
+ == 0.4.1 - 13-May-2006
117
+ * Fixed a bug where spaces in $LOAD_PATH would cause Process.fork to fail.
118
+ Thanks go to Justin Bailey for the spot and patch.
119
+ * Added a short synopsis to the README file.
120
+
121
+ == 0.4.0 - 7-May-2006
122
+ * Now pure Ruby, courtesy of the Win32API package.
123
+ * Now comes with a gem.
124
+ * Modified Process.kill to send a signal to the current process if pid 0
125
+ is specified, as per the current 1.8 behavior.
126
+ * Process.create now accepts the 'environment' key/value, where you can
127
+ pass a semicolon-separated string as the environment for the new process.
128
+ * Moved the GUI related options of Process.create to subkeys of the
129
+ 'startup_info' key. See documentation for details.
130
+ * Replaced Win32::ProcessError with just ProcessError.
131
+
132
+ == 0.3.3 - 16-Apr-2006
133
+ * Fixed a bug in Process.create with regards to creation_flags. Thanks go
134
+ to Tophe Vigny for the spot.
135
+
136
+ == 0.3.2 - 12-Aug-2005
137
+ * Fixed a bug in Process.kill where a segfault could occur. Thanks go to
138
+ Bill Atkins for the spot.
139
+ * Changed VERSION to WIN32_PROCESS_VERSION, because it's a module.
140
+ * Made the CHANGES, README and doc/process.txt documents rdoc friendly.
141
+ * Removed the process.rd file.
142
+
143
+ == 0.3.1 - 9-Dec-2004
144
+ * Modified Process.fork to return an actual PID instead of a handle. This
145
+ means that it should work with Process.kill and other methods that expect
146
+ an actual PID.
147
+ * Modified Process.kill to understand the strings "SIGINT", "INT", "SIGBRK",
148
+ "BRK", "SIGKILL" and "KILL". These correspond to signals 2, 3 and 9,
149
+ respectively.
150
+ * Added better $LOAD_PATH handling for Process.fork. Thanks go to Aslak
151
+ Hellesoy for the spot and the patch.
152
+ * Replaced all instances of rb_sys_fail(0) with rb_raise(). This is because
153
+ of a strange bug in the Windows Installer that hasn't been nailed down yet.
154
+ This means that you can't rescue Errno::ENOENT any more, but will have to
155
+ rescue StandardError. This only affects Process.kill.
156
+ * The signals that were formerly 1 and 2 and now 2 and 3. I did this because
157
+ I wanted the same signal number for SIGINT as it is on *nix.
158
+ * Added a test_kill.rb script under the examples directory.
159
+ * Other minor cleanup and corrections.
160
+
161
+ == 0.3.0 - 25-Jul-2004
162
+ * Added the create() method.
163
+ * Moved the example programs to doc/examples.
164
+ * Updated the docs, and toned down claims of fork's similarity to the Unix
165
+ version.
166
+ * Minor updates to the test suite.
167
+
168
+ == 0.2.1 - 17-May-2004
169
+ * Made all methods module functions, except fork, rather than singleton
170
+ methods.
171
+ * Minor doc changes.
172
+
173
+ == 0.2.0 - 11-May-2004
174
+ * Removed the Win32 module/namespace. You no longer 'include Win32' and you
175
+ no longer need to prefix Process with 'Win32::'.
176
+ * The fork() method is now a global function as well as a method of the
177
+ Process module. That means you can call 'fork' instead of 'Process.fork'
178
+ if you like.
179
+ * Doc updates to reflect the above changes.
180
+
181
+ == 0.1.1 - 6-Mar-2004
182
+ * Fixed bug where spaces in the directory name caused the fork() method to
183
+ fail (Park).
184
+ * Normalized tc_process.rb somewhat to make it easier to run outside of the
185
+ test directory if desired.
186
+ * Fixed up tc_process.rb a bit.
187
+
188
+ == 0.1.0 - 19-Feb-2004
189
+ * Initial release
data/MANIFEST CHANGED
@@ -1,11 +1,11 @@
1
- * CHANGES
2
- * README
3
- * MANIFEST
4
- * Rakefile
5
- * win32-process.gemspec
6
- * examples/test_create.rb
7
- * examples/test_fork_wait.rb
8
- * examples/test_fork_waitpid.rb
9
- * examples/test_kill.rb
10
- * lib/win32/process.rb
1
+ * CHANGES
2
+ * README
3
+ * MANIFEST
4
+ * Rakefile
5
+ * win32-process.gemspec
6
+ * examples/test_create.rb
7
+ * examples/test_fork_wait.rb
8
+ * examples/test_fork_waitpid.rb
9
+ * examples/test_kill.rb
10
+ * lib/win32/process.rb
11
11
  * test/tc_process.rb
data/README CHANGED
@@ -1,118 +1,117 @@
1
- = Description
2
- This package provides the fork, wait, wait2, waitpid, and waitpid2 methods
3
- for MS Windows. In addition, it provides a different implementation of the
4
- kill method, a proper implementation of Process.ppid, and decent analogues
5
- of Process.getpriority, Process.setpriority and Process.getrlimit.
6
-
7
- = Prerequisites
8
- Ruby 1.8.2 or later.
9
- The windows-pr library, 0.8.6 or later.
10
- The sys-proctable library, 0.7.6 or later (test suite only).
11
- The test-unit library, 2.0.3 or later (test suite only).
12
-
13
- = Supported Platforms
14
- This library is supported on Windows 2000 or later.
15
-
16
- = Installation Instructions
17
- rake test (optional)
18
- rake install (non-gem) or rake install_gem (gem)
19
-
20
- = Synopsis
21
- require 'win32/process'
22
-
23
- Process.fork{
24
- 3.times{
25
- puts 'In the child'
26
- sleep 1
27
- }
28
- }
29
-
30
- Process.wait
31
- puts 'Done'
32
-
33
- = Developer's Notes
34
- == The Process.fork and Process.wait methods
35
- The fork method is emulated on Windows by spawning another Ruby process
36
- against $PROGRAM_NAME via the CreateProcess() Win32 API function. It will
37
- use its parent's environment and starting directory.
38
-
39
- The various wait methods are a wrapper for the WaitForSingleObject() or
40
- WaitForMultipleObjects() Win32 API functions, for the wait* and waitpid*
41
- methods, respectively. In the case of wait2 and waitpid2, the exit value
42
- is returned via the GetExitCodeProcess() Win32API function.
43
-
44
- For now the waitpid and waitpid2 calls do not accept a second argument.
45
- That's because we haven't yet determined if there's a signal we should
46
- allow to be sent.
47
-
48
- IMPORTANT!
49
- Note that because fork is calling CreateProcess($PROGRAM_NAME), it will
50
- start again from the top of the script instead of from the point of the
51
- call. We will try to address this in a future release, if possible.
52
-
53
- == The Process.kill method
54
- Initially, the kill method will try to get a HANDLE on the PID using the
55
- OpenProcess() function. If that succeeds, we know the process is running.
56
-
57
- In the event of signal 2 or signal 3, the GenerateConsoleCtrlEvent()
58
- function is used to send a signal to that process. These will not kill
59
- GUI processes. It will not (currently) send a signal to remote
60
- processes.
61
-
62
- In the event of signal 1 or 4-8, the CreateRemoteThread() function is used
63
- after the HANDLE's process has been identified to create a thread
64
- within that process. The ExitProcess() function is then sent to that
65
- thread.
66
-
67
- In the event of signal 9, the TerminateProcess() function is called. This
68
- will almost certainly kill the process, but doesn't give the process a
69
- chance to necessarily do any cleanup it might otherwise do.
70
-
71
- == The Process.ppid method
72
- In MRI the Process.ppid always returns 0 on MS Windows. With this library
73
- it returns the actual parent pid.
74
-
75
- == Differences between Ruby's kill and the Win32 Utils kill
76
- Ruby does not currently use the CreateRemoteThread() + ExitProcess()
77
- approach which is, according to everything I've read, a cleaner approach.
78
- This includes not only online research but also Jeffrey Richter's
79
- "Advanced Windows Programming, 3rd Edition."
80
-
81
- Also, the way Process.kill handles multiple pids works slightly differently
82
- (and better IMHO) in the Win32 Utils version than the way Ruby currently
83
- provides.
84
-
85
- The reason Process.kill was originally added, in case anyone cares for
86
- historical trivia, is that Ruby 1.6.x did not support Process.kill on
87
- Windows at all.
88
-
89
- == Notes
90
- It is unlikely you will be able to kill system processes with this module.
91
- It's probably better that you don't.
92
-
93
- == Known Bugs
94
- None known (though please see the +Details+ section for quirks). Any
95
- bugs should be reported on the project page at
96
- http://rubyforge.org/projects/win32utils.
97
-
98
- == Future Plans
99
- Train Process.fork to execute from the point of the call rather than the
100
- top of the script (if possible).
101
-
102
- Other suggestions welcome.
103
-
104
- == License
105
- Artistic 2.0
106
-
107
- == Copyright
108
- (C) 2003-2009 Daniel J. Berger
109
- All Rights Reserved
110
-
111
- == Warranty
112
- This library is provided "as is" and without any express or
113
- implied warranties, including, without limitation, the implied
114
- warranties of merchantability and fitness for a particular purpose.
115
-
116
- == Author(s)
117
- Park Heesob
118
- Daniel J. Berger
1
+ = Description
2
+ This package provides the fork, wait, wait2, waitpid, and waitpid2 methods
3
+ for MS Windows. In addition, it provides a different implementation of the
4
+ kill method, a proper implementation of Process.ppid, and decent analogues
5
+ of Process.getpriority, Process.setpriority and Process.getrlimit.
6
+
7
+ = Prerequisites
8
+ Ruby 1.8.2 or later.
9
+ The windows-pr library, 0.8.6 or later.
10
+ The sys-proctable library, 0.7.6 or later (test suite only).
11
+ The test-unit library, 2.0.3 or later (test suite only).
12
+
13
+ = Supported Platforms
14
+ This library is supported on Windows 2000 or later.
15
+
16
+ = Installation
17
+ gem install win32-process
18
+
19
+ = Synopsis
20
+ require 'win32/process'
21
+
22
+ Process.fork{
23
+ 3.times{
24
+ puts 'In the child'
25
+ sleep 1
26
+ }
27
+ }
28
+
29
+ Process.wait
30
+ puts 'Done'
31
+
32
+ = Developer's Notes
33
+ == The Process.fork and Process.wait methods
34
+ The fork method is emulated on Windows by spawning another Ruby process
35
+ against $PROGRAM_NAME via the CreateProcess() Win32 API function. It will
36
+ use its parent's environment and starting directory.
37
+
38
+ The various wait methods are a wrapper for the WaitForSingleObject() or
39
+ WaitForMultipleObjects() Win32 API functions, for the wait* and waitpid*
40
+ methods, respectively. In the case of wait2 and waitpid2, the exit value
41
+ is returned via the GetExitCodeProcess() Win32API function.
42
+
43
+ For now the waitpid and waitpid2 calls do not accept a second argument.
44
+ That's because we haven't yet determined if there's a signal we should
45
+ allow to be sent.
46
+
47
+ IMPORTANT!
48
+ Note that because fork is calling CreateProcess($PROGRAM_NAME), it will
49
+ start again from the top of the script instead of from the point of the
50
+ call. We will try to address this in a future release, if possible.
51
+
52
+ == The Process.kill method
53
+ Initially, the kill method will try to get a HANDLE on the PID using the
54
+ OpenProcess() function. If that succeeds, we know the process is running.
55
+
56
+ In the event of signal 2 or signal 3, the GenerateConsoleCtrlEvent()
57
+ function is used to send a signal to that process. These will not kill
58
+ GUI processes. It will not (currently) send a signal to remote
59
+ processes.
60
+
61
+ In the event of signal 1 or 4-8, the CreateRemoteThread() function is used
62
+ after the HANDLE's process has been identified to create a thread
63
+ within that process. The ExitProcess() function is then sent to that
64
+ thread.
65
+
66
+ In the event of signal 9, the TerminateProcess() function is called. This
67
+ will almost certainly kill the process, but doesn't give the process a
68
+ chance to necessarily do any cleanup it might otherwise do.
69
+
70
+ == The Process.ppid method
71
+ In MRI the Process.ppid always returns 0 on MS Windows. With this library
72
+ it returns the actual parent pid.
73
+
74
+ == Differences between Ruby's kill and the Win32 Utils kill
75
+ Ruby does not currently use the CreateRemoteThread() + ExitProcess()
76
+ approach which is, according to everything I've read, a cleaner approach.
77
+ This includes not only online research but also Jeffrey Richter's
78
+ "Advanced Windows Programming, 3rd Edition."
79
+
80
+ Also, the way Process.kill handles multiple pids works slightly differently
81
+ (and better IMHO) in the Win32 Utils version than the way Ruby currently
82
+ provides.
83
+
84
+ The reason Process.kill was originally added, in case anyone cares for
85
+ historical trivia, is that Ruby 1.6.x did not support Process.kill on
86
+ Windows at all.
87
+
88
+ = Notes
89
+ It is unlikely you will be able to kill system processes with this module.
90
+ It's probably better that you don't.
91
+
92
+ = Known Bugs
93
+ None known (though please see the +Details+ section for quirks). Any
94
+ bugs should be reported on the project page at
95
+ http://rubyforge.org/projects/win32utils.
96
+
97
+ = Future Plans
98
+ Train Process.fork to execute from the point of the call rather than the
99
+ top of the script (if possible).
100
+
101
+ Other suggestions welcome.
102
+
103
+ = License
104
+ Artistic 2.0
105
+
106
+ = Copyright
107
+ (C) 2003-2010 Daniel J. Berger
108
+ All Rights Reserved
109
+
110
+ = Warranty
111
+ This library is provided "as is" and without any express or
112
+ implied warranties, including, without limitation, the implied
113
+ warranties of merchantability and fitness for a particular purpose.
114
+
115
+ = Author(s)
116
+ Park Heesob
117
+ Daniel J. Berger