User forums > General (but related to Code::Blocks)

signals and exit(0) aren't interpreted correctly

(1/3) > >>

jarro_2783:
If I set up a signal catcher like this:

signal(SIGINT, sigDestroy);

then in the signal catcher I call exit(0), when I press ctrl c, codeblocks still thinks the process terminated with status -282848 (or whatever it actually is). The other thing wierd that happens is if I ignore the signal from within the signal catcher like this:

signal(SIGINT, SIG_IGN);

codeblocks thinks the program terminated, but the program is still running withing console_runner.

Is this a bug?

Michael:
Hello,

If you give C::B revision and OS, it would be easier to help you.

Best wishes,
Michael

jarro_2783:
oh ok,

windows xp, I just downloaded the june 1st nightly build and it still does it.

jarro_2783:
bump

thomas:

--- Quote from: jarro_2783 on June 03, 2006, 02:59:04 am ---windows xp, I just downloaded the june 1st nightly build and it still does it.
--- End quote ---
Yes it is a bug. In your code though, not in Code::Blocks.
You cannot set signal handlers under Windows. This is a no-op. Therefore it still crashes, and hence the exit code.

EDIT:
Strictly speaking, the above is not correct, you can set signal handlers. However, this is a Windows XP feature which is not backwards-compatible, and you have to use Windows API calls for that. POSIX calls don't do anything (unless maybe you have this special Unix compatibility toolkit from Microsoft, I don't know about that).
The MSVC compiler has some builtin functionality that installs structured exception handlers behind the scenes, but this again only works under Windows XP and is non-standard (look on MSDN if you're interested in that).

Navigation

[0] Message Index

[#] Next page

Go to full version