Skip to content

Commit

Permalink
Merge pull request #3 from silverfin/rl-exit-code-for-stopped-service
Browse files Browse the repository at this point in the history
Add nonzero win32 exit code when stopping service in ensure block
  • Loading branch information
swistak35 authored Jan 25, 2023
2 parents 9b582e2 + d9d1842 commit 6319dc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/win32/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ class Daemon
# Main loop for the service.
while WaitForSingleObject(@@hStopCompletedEvent, 1000) != WAIT_OBJECT_0
end
ensure

# Stop the service.
SetTheServiceStatus.call(SERVICE_STOPPED, NO_ERROR, 0, 0)
ensure
# Stop the service.
# This ensures that if the main thread crashes and Service_Main thread is terminated, we will set nonzero win32exitCode
SetTheServiceStatus.call(SERVICE_STOPPED, 1, 0, 0)
end
end

Expand Down

0 comments on commit 6319dc9

Please sign in to comment.