mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-16 07:34:45 +03:00
c4ed1395d9
Operating system counter stores signals as flag set without counter. So sending two signals to a process may result to one or two signal handler invocation. Queueing signals inside Idris could give users false sense of signals being are queue, while they are not. In particular, test for signal could not work reliably for that reason. Also, practically we usually don't need have more than once signal event. This is follow-up to #1660. CC @mattpolzin
25 lines
927 B
Idris
25 lines
927 B
Idris
import System.Signal
|
|
import System
|
|
import Data.List
|
|
import Data.Fuel
|
|
|
|
main : IO ()
|
|
main = do
|
|
Right () <- collectSignal SigABRT
|
|
| Left (Error code) => putStrLn $ "error " ++ (show code)
|
|
Right () <- collectSignal SigILL
|
|
| Left (Error code) => putStrLn $ "error " ++ (show code)
|
|
putStrLn "before"
|
|
[Right (), Right (), Right ()] <- sequence $ replicate 3 (raiseSignal SigABRT)
|
|
| _ => putStrLn $ "got non-zero exit from a system call"
|
|
[Right (), Right (), Right ()] <- sequence $ replicate 3 (raiseSignal SigILL)
|
|
| _ => putStrLn $ "got non-zero exit from a system call"
|
|
sleep 1
|
|
[SigILL, SigABRT] <- handleManyCollectedSignals (limit 4)
|
|
| (_ :: _ :: []) => putStrLn "received the wrong signals."
|
|
| _ => putStrLn "did not receive expected number of signals."
|
|
putStrLn "after"
|
|
Right () <- defaultSignal SigABRT
|
|
| Left (Error code) => putStrLn $ "error " ++ (show code)
|
|
putStrLn "done."
|