# Kill process using WIN32\_PROCESS

**URL:** <https://www.ruby-forum.com/t/kill-process-using-win32-process/131628>\
**Category:** Ruby\
**Created:** [March 12, 2008, 12:52am UTC](https://www.ruby-forum.com/t/kill-process-using-win32-process/131628 "2008-03-12T00:52:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [March 12, 2008, 12:52am UTC](https://www.ruby-forum.com/t/kill-process-using-win32-process/131628/1 "2008-03-12T00:52:40Z")

</div>

I was reviewing the docs for Module Process in WIN32\_PROCESS and  
found the following docs for Kill. What does signal 4-8 do and how  
does it make it nicer kill. why is it 4-8 and what is the degree of  
niceness as it goes along.

kill(signal, \*pids)  
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.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [March 12, 2008, 2:48am UTC](https://www.ruby-forum.com/t/kill-process-using-win32-process/131628/2 "2008-03-12T02:48:46Z")

</div>

On Mar 11, 5:28 pm, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I was reviewing the docs for Module Process in WIN32\_PROCESS and  
> found the following docs for Kill. What does signal 4-8 do and how  
> does it make it nicer kill. why is it 4-8 and what is the degree of  
> niceness as it goes along.

Actually, it’s 1 and 4-8. Signals 2 and 3 were chosen for SIGINT and  
SIGBRK, respectively, because that’s what their Unix counterparts are  
(typically). In practice these will rarely be used.

They’re nicer because they use a different technique for killing a  
process than the 9 signal does. The 9 signal uses TerminateProcess()  
behind the scenes, which is a brute force way to kill a process that  
bypasses any exit handlers the process may have setup. Signals 1 and  
4-8 use a CreateRemoteThread() + ExitProcess() technique, which _does_  
allow the process to run any exit handlers first.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [March 13, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/kill-process-using-win32-process/131628/3 "2008-03-13T14:17:38Z")

</div>

On Mar 11, 9:38 pm, Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> They’re nicer because they use a different technique for killing a  
> process than the 9 signal does. The 9 signal uses TerminateProcess()  
> behind the scenes, which is a brute force way to kill a process that  
> bypasses any exit handlers the process may have setup. Signals 1 and  
> 4-8 use a CreateRemoteThread() + ExitProcess() technique, which _does_  
> allow the process to run any exit handlers first.
> 
> Regards,
> 
> Dan

is signal 4, 5, 6, 7,8 provide same effect or is 8 better than 7 in  
descending order

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [March 13, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/kill-process-using-win32-process/131628/4 "2008-03-13T16:51:32Z")

</div>

On Mar 13, 7:15 am, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > does it make it nicer kill. why is it 4-8 and what is the degree of  
> > > 4-8 use a CreateRemoteThread() + ExitProcess() technique, which _does_  
> > > allow the process to run any exit handlers first.
> 
> > Regards,
> 
> > Dan
> 
> is signal 4, 5, 6, 7,8 provide same effect or is 8 better than 7 in  
> descending order- Hide quoted text -

1 and 4-8 are all the same.

Regards,

Dan
