Bug: Stop-Process does not issue SIGTERM as expected.
See original GitHub issueSteps to reproduce
taskkill /IM "App With Tray Icon.exe"
Without moving mouse, tray icon disappears from tray immediately.
Stop-Process "App With Tray Icon"
Without moving mouse, tray icon is stays visible. Additionally, starting the process again will display a duplicate icon, the old one disappears when hovering over it.
Expected behavior
Stop-Process by default should be SIGTERM, graceful. SIGKILL should only be used after timeout or -FORCE is used.
Actual behavior
The old tray icon stays visible because app is killed. (This is not actually PowerShell specific, but a technical caveat when processes are killed.)
Workaround
Use taskkill in place of stop-process for processes that have tray icons.
Environment data
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.20215
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:55 (20 by maintainers)
Top Results From Across the Web
SIGTERM not working occasionally
The problem with this is it means the process cannot react and do whatever little things it needs to do before shutting down....
Read more >In what order should I send signals to gracefully shutdown ...
Given that the default signal sent by kill is SIGTERM , I would expect it is the most-commonly expected signal for graceful shutdown...
Read more >Inconsistent exitcode for terminated child processes on ...
I think that having results consistent with `os.kill(,SIGTERM)` would be desirable even if that means non-negative values. I'm willing to post a ...
Read more >Why SIGTERM signal does not work for process group?
I want to send SIGTERM signal to jboss when my script was killed, terminated or interrupted. But above code does not terminate JBoss....
Read more >Linux Graceful Termination | Exit code 143, Signal 15
Problem : NGINX does not perform graceful termination on SIGTERM. If you are using the official NGINX Ingress Controller, when the controller pod...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m on Windows with PowerShell 7.1.5. This behavior is quite unintuitive, because there is a
-Forceswitch butStop-Processalways acts as if it was on, killing a process without mercy instead of gracefully shutting it down. I’ve noticed this also happens with Task Manager - it doesn’t give you an option to request a process to terminate, allowing for cleanup routines to be run. Being mostly a Linux user, I’m used toSIGTERMing processes and onlySIGKILLing them as a last resort. Seems likeSIGKILLis the default expected behavior on Windows.In my use case, I’m dealing with console processes on a CI deployment pipeline so
CloseMainWindow()doesn’t apply. Usingtaskkillinstead as OP mentioned works as expected.I believe we should do the cmdlet too smart and complex. It is currently impossible to send an event or signal to a process so that it terminates gracefully.
The suggestion is to just add such a feature - just send the signal and nothing else.
All other smart things the user can do himself (or we can add later after receiving feedback).
We can implement this on Unix too https://stackoverflow.com/questions/41041730/net-core-app-how-to-send-sigterm-to-child-processes