Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit with non-zero exit code on exception #1783

Conversation

johan-ronnkvist
Copy link
Contributor

@johan-ronnkvist johan-ronnkvist commented Feb 14, 2023

Intent: Resolve issue #898

How:

Ensure that when the return value of Service_Run() is less than zero, we exit the service with an exit code of -1. This is done without setting the SERVICE_STOPPED state to indicate that this was not an intentional stop.

According to the Windows API documentation, this is the expectation from the system.

A service is considered failed when it terminates without reporting a status of SERVICE_STOPPED to the service controller.
Source

Why:

Enable services to communicate internal failures, so that an automatic restart policy can be applied.

Testing:

Testing has been done in a pair-dev setup with @TechnicalPirate.

@johan-ronnkvist johan-ronnkvist marked this pull request as ready for review February 14, 2023 14:40
@marcelotduarte
Copy link
Owner

marcelotduarte commented Feb 17, 2023

Compiler error:

"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\runneradmin\AppData\Local\Temp\build-env-e99xypbk\include -IC:\Users\runneradmin\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\pythonx86.3.7.9\tools\include -IC:\Users\runneradmin\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\pythonx86.3.7.9\tools\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcsource/bases/Win32Service.c /Fobuild\temp.win32-cpython-37\Release\source/bases/Win32Service.obj
  Win32Service.c
  source/bases/Win32Service.c(87): error C2143: syntax error: missing ')' before '='
  source/bases/Win32Service.c(87): error C2072: 'Service_SetStatus': initialization of a function
  source/bases/Win32Service.c(87): error C2059: syntax error: ')'
  source/bases/Win32Service.c(88): error C2143: syntax error: missing ';' before '{'
  source/bases/Win32Service.c(88): error C2449: found '{' at file scope (missing function header?)
  source/bases/Win32Service.c(110): error C2059: syntax error: '}'
  source/bases/Win32Service.c(212): warning C4013: 'Service_Stop' undefined; assuming extern returning int
  source/bases/Win32Service.c(283): error C2198: 'Service_SetStatus': too few arguments for call
  source/bases/Win32Service.c(552): error C2198: 'Service_SetStatus': too few arguments for call
  source/bases/Win32Service.c(613): error C2198: 'Service_SetStatus': too few arguments for call

@johan-ronnkvist johan-ronnkvist force-pushed the feature/return_non_zero_on_exception branch from 14b9de0 to 5e683ff Compare May 24, 2023 06:55
@marcelotduarte
Copy link
Owner

Thanks!

@marcelotduarte marcelotduarte merged commit 4c83e8a into marcelotduarte:main May 25, 2023
19 checks passed
marcelotduarte pushed a commit that referenced this pull request Jun 6, 2023
Co-authored-by: Johan Rönnkvist <johan.ronnkvist@king.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhandled python exceptions do not result in non-zero exit codes in Win32Services
2 participants