#1185: can't do I/O in the child of forkProcess with -threaded
----------------------------+-----------------------------------------------
 Reporter:  simonmar        |          Owner:             
     Type:  bug             |         Status:  new        
 Priority:  low             |      Milestone:  _|_        
Component:  Runtime System  |        Version:  6.6        
 Severity:  normal          |     Resolution:             
 Keywords:                  |     Difficulty:  Easy (1 hr)
 Testcase:                  |   Architecture:  Unknown    
       Os:  Unknown         |  
----------------------------+-----------------------------------------------
Comment (by tibbe):

 It doesn't work without `-threaded` either!

 My library exports the following function:

 {{{
 serve :: Application -> IO ()
 }}}

 Where `Application` is a handler type function in the spirit of `Request
 -> Response IO`.

 The intended usage is for the user who wants to build a web application to
 import my library and write a function e.g.

 {{{
 fileServer :: Application
 }}}

 and have a `main` that looks something like:

 {{{
 main = serve fileServer
 }}}

 The insides of the library are in principle those of HWS. `serve` reads
 lots of configuration flags such as `--port` and `--daemonize` from the
 command line so the user can get a functioning web application server that
 he or she can deploy in production with little fuzz.

 I can't see how I can support this interface and still fork in C. It seems
 to me like the user needs to write the startup code in C and call `main`
 from it. Not a nice user experience.

 If there is a way to write a C library that forks and include it in my
 library and still retain the same API I will of course use it as an
 intermediate solution but I still would prefer to be able to fork
 processes from inside Haskell. Forking, even in a restricted version, is
 something that would be useful in Haskell. I think daemonizing processes
 is a perfect example of where it's needed. I also think it is a necessary
 feature for server type applications.

 I understand that this might be difficult from a technical perspective,
 yet it is something other languages have so it must be possible. If I
 understood the issue better I could try to help come up with a solution
 and also try to implement it.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1185#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to