<div dir="ltr">For the purposes of profiling a partially evaluated program, I'm interested in knowing the best way to terminate a GHC program. This is useful for profiling programs that take a long time to run, possibly as long as forever. It appears that *if* the program can be terminated with a single ^c, then profiling information is written to output. Sometimes, a single ^c doesn't kill the program, at not before I get impatient and hit ^c again. Usually two ^c will kill the program, but then no profiling data is written to output. As a simple example,<div><br></div><div>Main.hs</div><div><div>fib n = fib (n - 1) + fib (n - 2)</div><div>main = print $ fib 100<br></div></div><div><br></div><div>Compiling with -prof and running with +RTS -p, I can kill this program with a *single* ^c in the first approximately 10 seconds of execution, but after that only two ^c will do the job. Looking at my resources, this change appears to coincide with the program using all of my physical memory and moving to swap space, however that could also be coincidental.</div><div><br></div><div>Why does ^c work sometimes, but not other times for the same program? What is the easiest way to ensure that profiling data will get printed when the program does not terminate on its own?</div></div>