diff --git a/Telegram.hs b/Telegram.hs index 53ed487..ec795a8 100644 --- a/Telegram.hs +++ b/Telegram.hs @@ -3,10 +3,8 @@ module Telegram where import Network import System.IO import System.Process -import System.Process.Internals -import System.Posix.Signals (signalProcess, sigKILL) -import Data.List.Utils (replace) -import Control.Monad (when, replicateM_) +import Data.List.Utils (replace) +import Control.Monad (when, replicateM_) import Control.Retry -- Parameters @@ -18,7 +16,7 @@ args = ["-d", "-P", show port] telegramProcess :: IO ProcessHandle telegramProcess = do - (_,_,_, handle) <- createProcess (proc program args) + (_,_,_, handle) <- createProcess (proc program args) { create_group = True } return handle @@ -30,10 +28,7 @@ telegramSocket = recoverAll timeout connect closeTelegram :: Handle -> ProcessHandle -> IO () closeTelegram socket handle = - hClose socket >> getPid handle >>= signalProcess sigKILL - where - go (OpenHandle h) = h - getPid h = withProcessHandle h (return . go) + hClose socket >> replicateM_ 2 (interruptProcessGroupOf handle) send :: Handle -> String -> IO ()