runtime: Mono does not emit ProcessExit event on SIGTERM.
To reproduce:
dotnet new web -o web
cd web
dotnet run
Find the pid of the dotnet run
process, and send it SIGTERM from another terminal:
kill -SIGTERM <pid>
With CoreCLR, the application shuts down, and the exit code is 0
:
...
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
$ echo $?
0
With Mono, the application keeps running, the dotnet run
process gets terminated:
Terminated
$ echo $?
143
The web
process is still running, you can send it SIGTERM seperately and it terminates nicely.
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...
This difference in behavior is causing one of the source-build smoke tests to fail: https://github.com/dotnet/source-build/issues/3174.
cc @akoeplinger
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 30 (29 by maintainers)
Commits related to this issue
- Provide fix for https://github.com/dotnet/runtime/issues/81093 "Mono does not emit ProcessExit event on SIGTERM" * src/mono/mono/mini/mini-posix.c - Add signal handler for SIGTERM - SIGTERM ha... — committed to nealef/runtime by nealef a year ago
- Provide fix for #81093 - "Mono does not emit ProcessExit event on SIGTERM" * src/mono/mono/mini/mini-posix.c - Add signal handler for SIGTERM * src/mono/mono/mini/mini-windows.c - Add signal han... — committed to nealef/runtime by nealef a year ago
The
HelloWorld
process is exiting with the correct value:An
strace
shows all the processes exiting with the desired value:I changed the
HelloWorld
program to do:And ran things again and this time looked at all the threads:
The
strace
showed:So I think it’s doing what it should. Should I generate a PR?
It doesn’t address it for Windows. I am attempting to mimic the behaviour of coreCLR but haven’t had enough free cycles to get it done.