Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Well, I'm a node.js developer. Node has a functionality that could send signals

## Features
- Support both **32bit** (Win32) & **64bit** (x64) Windows
- Support both ```SIGBREAK``` (Ctrl + Break) and ```SIGINT``` (Ctrl + C) Signals
- Support `SIGBREAK` (Ctrl + Break), `SIGINT` (Ctrl + C), and `SIGCLOSE` (click close button) Signals.
- A library that could be used directly (#include), As a static library (.lib) and a dynamic library (.dll)
- Prebuilt binaries and libraries

Expand Down Expand Up @@ -65,6 +65,14 @@ If signal sending was successful or any error occurred during the sending, appro
> windows-kill -2 1234
```

#### Sending SIGCLOSE (click close button) to sample 1234 PID
```bash
> windows-kill -SIGCLOSE 1234
```
```bash
> windows-kill -3 1234
```

#### List supported signal types
```bash
> windows-kill -l
Expand Down
2 changes: 1 addition & 1 deletion windows-kill-library/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace WindowsKillLibrary {
}

void Signal::validateType(DWORD_PTR type) {
if (!(type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)) {
if (!(type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT || type == CTRL_CLOSE_EVENT)) {
throw invalid_argument(string("EINVAL"));
}
}
Expand Down
7 changes: 7 additions & 0 deletions windows-kill-library/windows-kill-library.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ namespace WindowsKillLibrary {
/// </summary>
const DWORD SIGNAL_TYPE_CTRL_BREAK = CTRL_BREAK_EVENT;


/// <summary>
/// Signal type of Close console window same as Signal SIGTERM
/// </summary>
const DWORD SIGNAL_TYPE_CLOSE_EVENT = CTRL_CLOSE_EVENT;


/// <summary>
/// Sends the signal.
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion windows-kill/windows-kill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using std::exception;
using WindowsKillLibrary::sendSignal;
using WindowsKillLibrary::SIGNAL_TYPE_CTRL_C;
using WindowsKillLibrary::SIGNAL_TYPE_CTRL_BREAK;
using WindowsKillLibrary::SIGNAL_TYPE_CLOSE_EVENT;

#define WINDOWSKILL_VERSION "1.1.4"

Expand All @@ -37,7 +38,8 @@ int main(int argc,char *argv[])
else if (strcmp(argv[1], "-l") == 0) {
cout << "Availabe Signal Types\n"
<< "\t(1) (SIGBREAK) : CTR + Break\n"
<< "\t(2) (SIGINT) : CTR + C\n" << endl;
<< "\t(2) (SIGINT) : CTR + C\n"
<< "\t(3) (SIGCLOSE) : click close button\n" << endl;
}
else {
cout << "Not enough argument. Use -h for help." << endl;
Expand All @@ -51,6 +53,9 @@ int main(int argc,char *argv[])
else if (strcmp(argv[1], "-2") == 0 || strcmp(argv[1], "-SIGINT") == 0) {
signal_type = SIGNAL_TYPE_CTRL_C;
}
else if (strcmp(argv[1], "-3") == 0 || strcmp(argv[1], "-SIGCLOSE") == 0) {
signal_type = SIGNAL_TYPE_CLOSE_EVENT;
}
else {
cout << "Signal type " << argv[1] << " not supported. Use -h for help." << endl;
return 0;
Expand Down