propellor spin
This commit is contained in:
parent
63d7073308
commit
f373e73ada
|
@ -32,7 +32,6 @@ simpleSh namedpipe = do
|
||||||
forever $ do
|
forever $ do
|
||||||
(client, _addr) <- accept s
|
(client, _addr) <- accept s
|
||||||
h <- socketToHandle client ReadWriteMode
|
h <- socketToHandle client ReadWriteMode
|
||||||
hSetBuffering h LineBuffering
|
|
||||||
maybe noop (run h) . readish =<< hGetLine h
|
maybe noop (run h) . readish =<< hGetLine h
|
||||||
where
|
where
|
||||||
run h (Cmd cmd params) = do
|
run h (Cmd cmd params) = do
|
||||||
|
@ -47,6 +46,7 @@ simpleSh namedpipe = do
|
||||||
let runwriter = do
|
let runwriter = do
|
||||||
v <- readChan chan
|
v <- readChan chan
|
||||||
hPutStrLn h (show v)
|
hPutStrLn h (show v)
|
||||||
|
hFlush h
|
||||||
case v of
|
case v of
|
||||||
Done -> noop
|
Done -> noop
|
||||||
_ -> runwriter
|
_ -> runwriter
|
||||||
|
@ -73,8 +73,8 @@ simpleShClient namedpipe cmd params handler = do
|
||||||
s <- socket AF_UNIX Stream defaultProtocol
|
s <- socket AF_UNIX Stream defaultProtocol
|
||||||
connect s (SockAddrUnix namedpipe)
|
connect s (SockAddrUnix namedpipe)
|
||||||
h <- socketToHandle s ReadWriteMode
|
h <- socketToHandle s ReadWriteMode
|
||||||
hSetBuffering h LineBuffering
|
|
||||||
hPutStrLn h $ show $ Cmd cmd params
|
hPutStrLn h $ show $ Cmd cmd params
|
||||||
|
hFlush h
|
||||||
resps <- catMaybes . map readish . lines <$> hGetContents h
|
resps <- catMaybes . map readish . lines <$> hGetContents h
|
||||||
hClose h `after` handler resps
|
hClose h `after` handler resps
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue