Skip to content

Instantly share code, notes, and snippets.

@zxexz
Created October 28, 2017 04:30
Show Gist options
  • Save zxexz/06d296512303c3f795067dcb3a3ace73 to your computer and use it in GitHub Desktop.
Save zxexz/06d296512303c3f795067dcb3a3ace73 to your computer and use it in GitHub Desktop.
{-# 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