From 5c5eda9e8333bd652d0ea9cdbeb6fc4d5bdfe5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 26 Nov 2021 22:34:40 +0100 Subject: Separate constructors for internal process names --- src/Process.hs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Process.hs (limited to 'src/Process.hs') diff --git a/src/Process.hs b/src/Process.hs new file mode 100644 index 0000000..f409720 --- /dev/null +++ b/src/Process.hs @@ -0,0 +1,35 @@ +module Process ( + Process(..), + ProcName(..), + textProcName, unpackProcName, +) where + +import Control.Concurrent.STM + +import Data.Text (Text) +import qualified Data.Text as T + +import System.IO +import System.Posix.Signals +import System.Process + +data Process = Process + { procName :: ProcName + , procHandle :: ProcessHandle + , procStdin :: Handle + , procOutput :: TVar [Text] + , procKillWith :: Maybe Signal + } + +data ProcName = ProcName Text + | ProcNameTcpdump + | ProcNameGDB + deriving (Eq, Ord) + +textProcName :: ProcName -> Text +textProcName (ProcName name) = name +textProcName ProcNameTcpdump = T.pack "tcpdump" +textProcName ProcNameGDB = T.pack "gdb" + +unpackProcName :: ProcName -> String +unpackProcName = T.unpack . textProcName -- cgit v1.2.3