sindresorhus / fkill

Fabulously kill processes. Cross-platform.
MIT License
732 stars 34 forks source link

Windows - fkill error if process started with /min flag #47

Open FDiskas opened 3 years ago

FDiskas commented 3 years ago

"fkill": "^7.0.1"

spawn(`cmd`, ['/C', 'start /min altv-server.exe'], { detached: true, stdio: 'inherit' });

Error:

AggregateError: 
    Error: Killing process altv-server.exe failed: Command failed with exit code 128: taskkill /t /im altv-server.exe
        at Array.map (<anonymous>)
        at fkill (D:/server/node_modules/fkill/index.js:128:9)
        at runMicrotasks (<anonymous>)
    at fkill (D:\server\node_modules\fkill\index.js:128:9)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
...

Actually windows throws the error: taskkill /t /im altv-server.exe

ERROR: The process with PID 5684 (child process of PID 22572) could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
MarkTiedemann commented 3 years ago

@FDiskas Did you use the force option? As the error message says, [t]his process can only be terminated forcefully.

FDiskas commented 3 years ago

I did nothing special. I thought that fkill should handle that

MarkTiedemann commented 3 years ago

Using force: true is potentially dangerous (for example, force killing a system process). Hence, the default value is false.

FDiskas commented 3 years ago

so that means if I start process in minimized window I can only force kill it? Can this be detected in fkill and used that flag instead throwing error?

MarkTiedemann commented 3 years ago

so that means if I start process in minimized window I can only force kill it?

I don't think that the minimized windows is the reason for it. Perhaps it was to do with signals not being handled correctly. This needs more investigation.

Can this be detected in fkill and used that flag instead throwing error?

No, because, even if it was because of the minimized window, there are other minimized windows that are potentially dangerous to kill.

Again, I'd recommend to use force: true, as suggested by the error message.