logo       

Trouble with hDuplicateTo before exec: msg#00075

lang.haskell.glasgow.bugs

Subject: Trouble with hDuplicateTo before exec

Hello.

"hDuplicateTo src tgt" overwrites the tgt handle with the src handle, but it
doesn't overwrite the file descriptor used by tgt with that used by src.
Rather, it makes a copy of src's fd and makes the overwritten tgt use that.

That's fine as long as we're in Haskell. But consider "hDuplicateTo h stdin".
When calling executeFile afterwards, the replaced process expects its
standard input on handle 0, not on the new fd generated by hDuplicateTo.

A workaround would be to use dupTo instead of hDuplicateTo, if we intend to
call executeFile afterwards, but I have the case that this isn't known at the
time. I'm forking a supplied IO action, connecting it with a pipe. The IO
action may or may not call executeFile.

Regards,
V.W.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise