finalizers on handles
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Wed Jun 24 01:03:28 EDT 2009
On Jun 24, 2009, at 00:52 , Ganesh Sittampalam wrote:
> On Tue, 23 Jun 2009, Brandon S. Allbery KF8NH wrote:
> On Jun 23, 2009, at 09:41 , Simon Marlow wrote:
>>>> main = do
>>>> (ih, oh, _, _) <- runInteractiveProcess "cat" [] Nothing Nothing
>>>> comphszp <- hGetContents oh
>>>> print (length comphszp)
>>>> -- hClose ih -- with this line they both deadlock
>>
>>
>> Note that you can trigger this in any language; it's a classic
>> beginner error with pipes (see, for example, the documentation for
>> open2/open3 in Perl or Python for other examples). Detecting this
>> in the type system would be an interesting idea, but de facto I
>> think this is a "it hurts when I do this".
>
> Sure - but it hurts more when in some environments you get away with
> it and others you don't.
You'll still have that though, it'll just be a different set of
environments. The next failure mode after this one is writing more
than _PIPE_BUF down ih; you'll deadlock in the write when in blocking
mode, in non-blocking mode it depends on how the runtime handles
partial writes.
--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20090624/8b243c2f/PGP.bin
More information about the Glasgow-haskell-users
mailing list