क्या सिस्टम पर कुछ ऐसा है। विंडोज़ पर पॉसिक्स?हैकेल के साथ विंडोज़ पर सिग्नल कैसे संभालें?
मैं नीचे दिए गए कोड को विंडोज़ पर चलाने के लिए चाहता हूं, क्या मुझे इसे बदलना चाहिए?
import IO
import Control.Exception hiding (catch)
import Control.Concurrent
import Network
import System.Posix ---cannot be run on windows.
main = withSocketsDo (installHandler sigPIPE Ignore Nothing >> main')
--so the signal handler cannot be used
main' = listenOn (PortNumber 9900) >>= acceptConnections
acceptConnections sock = do
putStrLn "trying to accept" -- debug msg
[email protected](h,host,port) <- accept sock
print conn -- debug msg
forkIO $ catch (talk conn `finally` hClose h) (\e -> print e)
acceptConnections sock
talk [email protected](h,_,_) = hGetLine h >>= hPutStrLn h >> hFlush h >> talk conn
उदाहरण के लिए
, अगर मैं कार्यक्रम चाहते हैं जब CTRL + C, मैं SIGINT के लिए कोई हैंडलर जोड़ना होगा C++ हां, तो बाहर निकलने के लिए, इस तरह की कुछ कोड लिखें:
void callback(int sig)
{
// printf("catch\n");
}
...
signal(SIGINT,callback);
लेकिन मैं डॉन हैकेल में ऐसा करने के बारे में नहीं पता, एफएफआई का उपयोग करें?