Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:01:23+00:00 2026-06-03T17:01:23+00:00

Is there something like System.Posix on windows? I want the code below to run

  • 0

Is there something like System.Posix on windows?

I want the code below to run on windows, should I change it?

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
        conn@(h,host,port) <- accept sock
        print conn -- debug msg
        forkIO $ catch (talk conn `finally` hClose h) (\e -> print e)
        acceptConnections sock

talk conn@(h,_,_) = hGetLine h >>= hPutStrLn h >> hFlush h >> talk conn

for example ,if I want the program to quit when ctrl+c,I must add a handler for SIGINT ,so in c++,write some code like this:

void callback(int sig) 
{ 
   // printf("catch\n"); 
} 
... 
signal(SIGINT,callback); 

But I don’t know how to do this in haskell,use FFI?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:01:27+00:00Added an answer on June 3, 2026 at 5:01 pm
    import Foreign
    import Foreign.C.Types
    
    type Handler = CInt->IO ()
    foreign import ccall "wrapper"
      genHandler:: (Handler) -> IO (FunPtr Handler)
    
    foreign import ccall safe "signal.h signal"
            install:: CInt->FunPtr Handler->IO CInt
    main=do
            s<-genHandler (\x->putStrLn $ "catch "++(show x))
            res<- install 2 s
            putStrLn $ show res
            s<-getLine
    

    the code above is what i wanna do,just import the signal function,with a haskell callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to access the windows registry system using coldfusion. Something like
Is there something like SESSION in Windows application? I want to store a few
Is there something like VSTS2010 Team System Web Access (TSWA), if yes where is
is there something like API built atop the standard ProcessBuilder for calling system programs?
I have a code that should run on both windows and unix systems (Mac,
Is there something like serialize/unserialize PHP functions in jQuery? These functions return a string
Is there something like die in JavaScript? I've tried with break, but doesn't work
Is there something like the following in Apache Common Lang or Spring Utils or
Q1: Is there something like too much ajax?? Explanation: I have been seeing programmers
I'm working on a game bot. I'd like to place there something like a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.