Hello, I am trying to write my own pOpen for Haskell. I have a version that works fine in GHC, but I can't quite make it work in Hugs. There are two things missing: the ability to fork and the ability to install a signal handler for SIGPIPE. First, on the forking. There is a vague note on http://cvs.haskell.org/Hugs/pages/libstatus.html about co-operative concurrency. I don't understand why this is relevant. If I want to fork, let me fork; using a low-level function implies that the programmer knows what's going on anyway. I have no intention of using any other sort of concurrency in this program, so there should be no problem. Moreover, Hugs has a call to system(), which internally must use fork() anyway. (I'm puzzled why rawSystem() is missing; somewhere, FFI must have been used to get to system(), right?) The same note applies to signals, and again, I'm not sure why. Also, Hugs doesn't seem to have System.Process, though there's no note explaining why it is not present. I'm probably missing something important here, but I can't figure out what it is. Lacking these functions really diminishes Hugs' usefulness as a scripting language to me, which is a shame; it would make a great one. Thanks, -- John
On Sat, Apr 16, 2005 at 12:47:39PM +0000, John Goerzen wrote:
I am trying to write my own pOpen for Haskell. I have a version that works fine in GHC, but I can't quite make it work in Hugs. There are two things missing: the ability to fork and the ability to install a signal handler for SIGPIPE.
First, on the forking. There is a vague note on http://cvs.haskell.org/Hugs/pages/libstatus.html about co-operative concurrency.
That page was a little out of date: - System.Process is missing; the chief problem is Hugs's representation of handles. Perhaps not insuperable. - System.Posix.Process.forkProcess is probably approximately implementable, modulo problems with handles. - System.Cmd.rawSystem is present.
The same note applies to signals, and again, I'm not sure why.
System.Process.Signals.installHandler requires execution of an arbitrary IO action at an arbitrary point in the program, and Hugs can't do pre-emption. So it seems it's not going to work with hugs98-Mar2005. Hopefully a future version will have System.Process.
On Mon, Apr 18, 2005 at 01:12:45AM +0100, ross@soi.city.ac.uk wrote:
First, on the forking. There is a vague note on http://cvs.haskell.org/Hugs/pages/libstatus.html about co-operative concurrency.
That page was a little out of date:
- System.Process is missing; the chief problem is Hugs's representation of handles. Perhaps not insuperable. - System.Posix.Process.forkProcess is probably approximately implementable, modulo problems with handles.
Can you elaborate a bit on what these problems are?
System.Process.Signals.installHandler requires execution of an arbitrary IO action at an arbitrary point in the program, and Hugs can't do pre-emption.
Ahh. OK. Actually, I am more interested in installing SIG_IGN for SIGPIPE. (That is, tell the system to ignore that signal.) That much should be doable, right? Thanks, John
On Mon, Apr 18, 2005 at 10:48:38AM -0500, John Goerzen wrote:
On Mon, Apr 18, 2005 at 01:12:45AM +0100, ross@soi.city.ac.uk wrote:
- System.Process is missing; the chief problem is Hugs's representation of handles. Perhaps not insuperable. - System.Posix.Process.forkProcess is probably approximately implementable, modulo problems with handles.
Can you elaborate a bit on what these problems are?
Hugs implements Handles on top of FILEs, so you have to worry about buffering. Most of it is probably possible, just not trivial.
Actually, I am more interested in installing SIG_IGN for SIGPIPE. (That is, tell the system to ignore that signal.) That much should be doable, right?
Should be. The higher-level System.Process seems more important, though.
participants (3)
-
John Goerzen -
Ross Paterson -
ross@soi.city.ac.uk