1

For example calling exit(100) would exit the application with status 100, and calling raise(SIGABRT) aborts the application with status 134 while creating a core dump. But what if I want the core dump with status 100 or any other arbitrary value. How can I do that ? I know there are several signals that triggers a core dump, but they seem to have fixed exit statuses.

Zitrax
  • 19,036
  • 20
  • 88
  • 110
  • 2
    Why would you do that? The whole point is to be able to tell whether it exited with dumping core. Most programs that pay attention to exit statuses should just differentiate between zero (success) and non-zero (failure), but some program might be interested in knowing if it failed while dumping core, in which case this particular exit code is useful... and forcing some other exit code would deceive the programs that depend on it for this. – Michael Aaron Safyan Apr 09 '10 at 13:50
  • Yes, but this is not for released software, only for internal debugging to be able to more easily categorize the dump without actually inspecting it with external tools. – Zitrax Apr 09 '10 at 14:02

2 Answers2

2

Looks like 134 equals to (128+6) and euqals to ((1<<7) | 6) (where #define SIGABRT 6)
Co-incidence?

ony
  • 12,457
  • 1
  • 33
  • 41
2

Well, I suppose you could fork() and have the parent call _exit(100), and the child call abort()...

I concur with the comments saying that it's a bad idea, though.

caf
  • 233,326
  • 40
  • 323
  • 462