Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For Ctrl-C and longjmp(), are you talking about builtin shell commands? I think it will "just work" for external processes. They receive SIGINT and terminate, and then the shell gets control again.

I guess I need to do a test of doing some expensive computation in bash, and then hitting Ctrl-C. Like doing the mandelbrot set or something.



Hello, World test case:

  bash$ while true ; do : ; done
  ^C
  bash$


Good tip, thanks!

I think you can use any of C++ exceptions, explicit returns, or setlongjmp(). setlongjmp() doesn't work well with C++ destructors. The interpreter loop just has to check for a flag set by the signal handler and then pop back to the interactive loop.

I noticed that the Lua parser uses setlongjmp() when compiled as C, but C++ exceptions when compiled as C++.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: