[Haskell-cafe] Re: catting to cat gets stuck at > 135K
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Thu Nov 27 11:38:35 EST 2008
On 2008 Nov 27, at 8:51, Simon Marlow wrote:
> Brandon S. Allbery KF8NH wrote:
>> On 2008 Nov 10, at 19:04, Jason Dusek wrote:
>>>>> simple exe bytes args = do
>>>>> (i, o, e, p) <- runInteractiveProcess exe args Nothing
>>>>> Nothing
>>>>> hPut i bytes
>>>>> s <- hGetContents o
>>>>> hClose i
>>>>> return s
>>>>
>>>> Yep, that's your problem. forkIO the hPut.
>>>
>>> Maybe I didn't do enough here -- just wrapping in `forkIO`
>>> does not seem to actually help.
>> *sigh* I hate the ghc runtime... it works in ghci, or compiled with
>> -threaded.
>
> Would you hate it less if -threaded were the default?
>
>> Otherwise you still get the deadlock because it only switches
>> threads under limited circumstances (garbage collections?)
>
> No, the issue is that without real OS threads, a foreign call can't
> be pre-empted (pretty obvious when you think about it).
> waitForProcess ends up making a blocking foreign call - non-obvious,
> but at least it's documented.
The way this is usually handled in the non-threaded case is to either
use SIGCHLD or non-blocking waitpid() so that "green" threads can
continue running. I'm a little surprised this wasn't done.
--
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
More information about the Haskell-Cafe
mailing list