Re: [Haskell-cafe] FFI: how to handle external dll crashes

2013-09-29 Thread kudah
On Mon, 23 Sep 2013 15:32:35 +0200 Miro Karpis wrote: > Thanks for that. I checked forkProcess - which is packed in POSIX > module. I'm building under windows. Do I need to go via cygwin, is > there some other way for creating new OS process? Windows doesn't support fork(), you'll need to either

Re: [Haskell-cafe] FFI: how to handle external dll crashes

2013-09-23 Thread Miro Karpis
Thanks for that. I checked forkProcess - which is packed in POSIX module. I'm building under windows. Do I need to go via cygwin, is there some other way for creating new OS process? m. On Mon, Sep 23, 2013 at 1:46 PM, Niklas Hambüchen wrote: > Hey, > > I don't think any of your code actually

Re: [Haskell-cafe] FFI: how to handle external dll crashes

2013-09-23 Thread Niklas Hambüchen
Hey, I don't think any of your code actually forks of an *OS process*. There three main kinds of threading constructs: * Haskell threads (forkIO) * Operating System threads (forkOS) * Operating System processes (forkProcess, fork() in C) Async uses the first one, you will need last one (which i

Re: [Haskell-cafe] FFI: how to handle external dll crashes

2013-09-23 Thread Miro Karpis
Hi Niklas, I think that I'm doing this in my try2 function with tryAny and catchAny functions. Unfortunately that didn't work. I'm just starting with Haskell so maybe also my implementation of my haskell code is not 100% correct. cheers, m. On Mon, Sep 23, 2013 at 1:36 PM, Niklas Hambüchen wrot

Re: [Haskell-cafe] FFI: how to handle external dll crashes

2013-09-23 Thread Niklas Hambüchen
If you cannot do it with Haskell exceptions, I guess you need to look how you would do it in plain C in do the same. Keep in mind that if something crashes in a C library, that library might have corrupted (or leaked) any memory it had access to. I guess a somewhat reliable way is to fork an OS

[Haskell-cafe] FFI: how to handle external dll crashes

2013-09-23 Thread Miro Karpis
Please, can you help me with following: I have an external dll that I'm importing in my haskell program. In some particular cases the dll crashes. Simplified: first I need to send to dll with MethodA some parameters and then call MethodB to do some calculations on those parameters. If I didn't giv