Created
October 28, 2017 04:30
-
-
Save zxexz/06d296512303c3f795067dcb3a3ace73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecordWildCards #-} | |
import System.IO | |
import System.Posix.IOCtl | |
import System.Posix.IO | |
import Foreign.Storable | |
import Foreign.Ptr | |
import Foreign.C | |
data Req = Req { c :: CChar } | |
instance Storable Req where | |
sizeOf _ = 1 | |
alignment _ = 1 | |
peek p = do c <- peekByteOff p 0; | |
return Req {..} | |
poke p Req {..} = pokeByteOff p 0 c | |
data TIOCSTI = TIOCSTI | |
instance IOControl TIOCSTI Req where | |
ioctlReq _ = 0x5412 | |
main :: IO () | |
main = do | |
fd <- openFd "/dev/pts/9" ReadWrite Nothing defaultFileFlags | |
ioctl' fd TIOCSTI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment