Skip to content
Snippets Groups Projects
Commit 309f3078 authored by Jens Nolte's avatar Jens Nolte
Browse files

Remove broken SIGTERM handler

parent 681a8ad3
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ import QBar.BlockOutput ...@@ -7,7 +7,7 @@ import QBar.BlockOutput
import QBar.Core import QBar.Core
import QBar.Time import QBar.Time
import Control.Concurrent (ThreadId, forkIO, forkFinally, threadDelay, myThreadId, throwTo) import Control.Concurrent (forkIO, forkFinally, threadDelay)
import Control.Concurrent.Async (async, wait) import Control.Concurrent.Async (async, wait)
import qualified Control.Concurrent.Event as Event import qualified Control.Concurrent.Event as Event
import Control.Concurrent.MVar (MVar, newMVar, modifyMVar_, swapMVar) import Control.Concurrent.MVar (MVar, newMVar, modifyMVar_, swapMVar)
...@@ -19,11 +19,9 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef) ...@@ -19,11 +19,9 @@ import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Maybe (catMaybes, mapMaybe) import Data.Maybe (catMaybes, mapMaybe)
import qualified Data.Text.Lazy as T import qualified Data.Text.Lazy as T
import Pipes import Pipes
import System.Exit
import System.IO (stderr, hPutStrLn) import System.IO (stderr, hPutStrLn)
import System.Posix.Process (createSession) import System.Posix.Signals (Handler(..), sigCONT, installHandler)
import System.Posix.Signals (Handler(..), sigTERM, sigCONT, signalProcessGroup, installHandler)
import System.Posix.Types (ProcessGroupID)
data HostHandle = HostHandle { data HostHandle = HostHandle {
barUpdateEvent :: BarUpdateEvent, barUpdateEvent :: BarUpdateEvent,
...@@ -34,23 +32,12 @@ data HostHandle = HostHandle { ...@@ -34,23 +32,12 @@ data HostHandle = HostHandle {
} }
installSignalHandlers :: Bar -> IO () installSignalHandlers :: Bar -> IO ()
installSignalHandlers bar = do installSignalHandlers bar = void $ installHandler sigCONT (Catch sigContAction) Nothing
mainThread <- myThreadId
processGroup <- createSession
void $ installHandler sigCONT (Catch sigContAction) Nothing
void $ installHandler sigTERM (Catch $ sigTermAction mainThread processGroup) Nothing
where where
sigContAction :: IO () sigContAction :: IO ()
sigContAction = do sigContAction = do
hPutStrLn stderr "SIGCONT received" hPutStrLn stderr "SIGCONT received"
updateBarDefault' bar updateBarDefault' bar
sigTermAction :: ThreadId -> ProcessGroupID -> IO ()
sigTermAction mainThread processGroup = do
void $ installHandler sigTERM Ignore Nothing
hPutStrLn stderr "SIGTERM received"
hPutStrLn stderr "Killing process group"
signalProcessGroup sigTERM processGroup
throwTo mainThread $ ExitFailure 143
eventDispatcher :: Bar -> IORef [(T.Text, BlockEventHandler)] -> Consumer BlockEvent IO () eventDispatcher :: Bar -> IORef [(T.Text, BlockEventHandler)] -> Consumer BlockEvent IO ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment