Re: finally part run twice on Ctrl-C

I've got the following code:
import Control.Exception import System.Cmd main = system "sleep 1m" `finally` putStrLn "goodbye"
When compiled with GHC 6.10.1.20090225, if I hit Ctrl-C during the sleep, I get the goodbye printed twice. If I leave evaluation to finish normally I get goodbye once. Is this a bug?
Dear Neil, et al. Just to let you know; I tried it on the release version of 6.10.1 and it worked as expected (first run, I waited; second I pressed Ctrl-C): *Test> main goodbye ExitSuccess *Test> main goodbye ExitFailure 2 *Test> If not coming from system differences, the bug should sit in recent code. Regards, Philip

Hi Philip,
Just to let you know; I tried it on the release version of 6.10.1 and it worked as expected (first run, I waited; second I pressed Ctrl-C):
*Test> main goodbye ExitSuccess *Test> main goodbye ExitFailure 2 *Test>
It looks like you are running in GHCi, which I think works. It's only when the program is compiled and run from the command line (Cygwin or DOS) that I get the above problem. Thanks Neil;

On Friday 27 February 2009 09:39:14 Neil Mitchell wrote:
It looks like you are running in GHCi, which I think works. It's only when the program is compiled and run from the command line (Cygwin or DOS) that I get the above problem.
Dear Neil, You were right. When I do compile it, though, I get the same (correct) behaviour (now I pressed Ctrl-C the first run and let it be for the second): holzensp@ewi1043:~/tmp> ghc Test.hs holzensp@ewi1043:~/tmp> ./a.out goodbye holzensp@ewi1043:~/tmp> ./a.out goodbye holzensp@ewi1043:~/tmp> This is on Linux, though, so it may also be OS-dependent. Regards, Philip

Hi I have filed bug http://hackage.haskell.org/trac/ghc/ticket/3081 to track this issue, marking it as effecting Windows only. Thanks Neil On Fri, Feb 27, 2009 at 8:45 AM, Philip K.F. Hölzenspies
On Friday 27 February 2009 09:39:14 Neil Mitchell wrote:
It looks like you are running in GHCi, which I think works. It's only when the program is compiled and run from the command line (Cygwin or DOS) that I get the above problem.
Dear Neil,
You were right. When I do compile it, though, I get the same (correct) behaviour (now I pressed Ctrl-C the first run and let it be for the second):
holzensp@ewi1043:~/tmp> ghc Test.hs holzensp@ewi1043:~/tmp> ./a.out goodbye holzensp@ewi1043:~/tmp> ./a.out goodbye holzensp@ewi1043:~/tmp>
This is on Linux, though, so it may also be OS-dependent.
Regards, Philip
participants (2)
-
Neil Mitchell
-
Philip K.F. Hölzenspies