From 17d46c67fa020b79ce6d31557136a66f66d673af Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 18:21:54 -0400 Subject: docker: When running as effective init inside container, wait on zombies. --- Propellor/SimpleSh.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Propellor/SimpleSh.hs') diff --git a/Propellor/SimpleSh.hs b/Propellor/SimpleSh.hs index 0999be9a..99a6fc24 100644 --- a/Propellor/SimpleSh.hs +++ b/Propellor/SimpleSh.hs @@ -9,7 +9,6 @@ import Network.Socket import Control.Concurrent.Chan import Control.Concurrent.Async import System.Process (std_in, std_out, std_err) -import System.Exit import Propellor import Utility.FileMode @@ -18,7 +17,7 @@ import Utility.ThreadScheduler data Cmd = Cmd String [String] deriving (Read, Show) -data Resp = StdoutLine String | StderrLine String | Done ExitCode +data Resp = StdoutLine String | StderrLine String | Done deriving (Read, Show) simpleSh :: FilePath -> IO () @@ -49,7 +48,7 @@ simpleSh namedpipe = do v <- readChan chan hPutStrLn h (show v) case v of - Done _ -> noop + Done -> noop _ -> runwriter writer <- async runwriter @@ -58,8 +57,10 @@ simpleSh namedpipe = do void $ concurrently (mkreader StdoutLine outh) (mkreader StderrLine errh) + + void $ tryIO $ waitForProcess pid - writeChan chan . Done =<< waitForProcess pid + writeChan chan Done wait writer -- cgit v1.2.3