From 184db7db1e89ed37158222e4948e7e425c67c3f7 Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Tue, 29 Oct 2019 14:22:13 +0100 Subject: [PATCH] waitpid() called when stopping services. --- src/service/service.cr | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/service/service.cr b/src/service/service.cr index 6f15b24..8955f4c 100644 --- a/src/service/service.cr +++ b/src/service/service.cr @@ -15,6 +15,19 @@ def split_command(string) return command, args end +lib C + fun waitpid(pid : Int32, status_ptr : Int32*, options : Int32) : Int32 +end + +class Process + def self.waitpid(pid) + options = 0 + status_ptr = uninitialized Int32 + + C.waitpid(pid, pointerof(status_ptr), options) + end +end + class Service getter environment : Environment getter providers = ProvidersList.new @@ -295,6 +308,8 @@ class Service else Process.kill Signal::TERM, _pid end + + Process.waitpid _pid else # Already stopped or dead, nothing to be done here. end