Getting the file descriptor of a handle, without closing it
Volker Wysk
pf3 at volker-wysk.de
Mon Mar 12 15:48:14 CET 2012
Am Montag 12 März 2012, 12:31:27 schrieb Simon Marlow:
> On 11/03/2012 01:31, Volker Wysk wrote:
> > However, I want to use it with stdin, stdout and stderr, only.
>
> Is there some reason you can't just use 0, 1, and 2?
This is complicated. I want to be able to fork a child action, and communicate
with it through stdin/stdout. I also want to be able to replace the child with
an external program, and communicate with it through a stdout-stdin pipe.
Something like this:
subproc (outm "Durch die Röhre" -|- exec "/bin/cat" [])
I don't rely on stdin/-out/-err still being open. One might be closed, and the
file descriptor might be reallocated (for a subsequently opened file or
whatever). I also don't rely on stdin being fd 0, stdout being fd 1, stderr
being fd 2.
If you really want to know what's going on, here is the documentation:
http://volker-wysk.de/hsshellscript/apidoc/HsShellScript.html#v%3Aexecute_file
> > These three
> > should never be garbage collected, should they? I think it would be safe
> > to use unsafeWithHandleFd this way. Am I right?
>
> I wouldn't do that, but you're probably right that it is safe right now.
> (but no guarantees that it will continue to work for ever.)
So I need a fixed unsafeWithHandleFd, for it to work forever?
I guess, I'll leave it as it is, for now.
Cheers
Volker
More information about the Glasgow-haskell-users
mailing list