You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance node's process.kill to support signals in Windows
4
+
Enhance node's ```process.kill``` to support signals in Windows
5
5
6
6
## Installation
7
7
```
@@ -11,20 +11,29 @@ $ npm install windows-kill
11
11
## Features
12
12
* No code change is needed. Just old ```process.kill``` calls.
13
13
* Support Both x86 & x64 Windows
14
-
* No effect on ***Non Windows*** operation systems (Linux, Mac OS X, ...)
14
+
* No effect on ***Non Windows*** operation systems (Linux, Mac OS X, etc...)
15
15
* Support both ```SIGINT``` and ```SIGBREAK``` (Just the two signals that are available on Windows)
16
16
17
17
## Why windows-kill?
18
-
Sending signal to another process, just by knowing it's PID, is not availabe at Windows OS. It's a UNIX-like feature. But, sending signal to other process, for telling it that something is going to happen to you, is a way to give other process some time for gracefull shutdown/restart. windows-kill tries to fix this issue by bringing the ability to send signals, ```SIGINT``` and ```SIGBREAK```, to another process by PID.
18
+
Sending signal to another process, just by knowing it's PID, is not available at Windows OS. It's a POSIX OSes feature. But, sending signal to other process, for telling it that something is going to happen to you, is a way to give other process some time for graceful shutdown/restart. windows-kill tries to fix this issue by bringing the ability to send signals, ```SIGINT``` and ```SIGBREAK```, to another process by **PID**.
19
+
20
+
## How it works?
21
+
To read a detailed info please visit [windows-kill-library Readme](https://github.com/alirdn/windows-kill/tree/master/windows-kill-library#how-it-works).
22
+
23
+
### Limitations
24
+
To send the signal, **windows-kill** at first send a same signal to the process that is calling it, to find a thread address. Then the founded address is used to send the real signal. Because of this, the process that is sending the signal will get the same signal too. But windows-kill register a signal handle during this procedure, so the process will not terminate. But if the process that is sending signal has child process, or is a child process of another process, sending signal will trigger the signal handles in other process in the same process group. And the default behavior of Windows console/application in case of getting a ```SIGINT``` or ```SIGBREAK```, is to terminate.
25
+
To **sum up**, If you are sending signal in node app that has child process (any kind of it), or is a child process of another process, the result is the termination of all the processes in the same process group, except the sender (well if it's a child process, because the master is terminated, it will terminate too).
26
+
27
+
**PS**: Currently there is no solution for this problem. But I'm working on it, to find a solution.
19
28
20
29
## Usage
21
30
```windows-kill``` expose a function. Simply run the exposed function with/without the options. Thats it. It should be called before any usage of ```process.kill```.
22
31
23
-
By default, ```windows-kill``` will enhance the node's process.kill in a way, that no code changes are needed in your codebase. Ehnance means that ```windows-kill``` will replace the node's ```process.kill``` with a custom function with the same arguments and behaviour. Just some changes to acheive signaling in Windows.
32
+
By default, ```windows-kill``` will enhance the node's process.kill in a way, that no code changes are needed in your codebase. Enhance means that ```windows-kill``` will replace the node's ```process.kill``` with a custom function with the same arguments and functionality. Just some changes to achieve signaling in Windows.
0 commit comments