aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Bristot de Oliveira <bristot@redhat.com>2020-10-21 18:25:59 +0200
committerDaniel Bristot de Oliveira <bristot@redhat.com>2020-10-21 18:25:59 +0200
commit840a2b3277fe3ea6348da6f060979ac80577bb03 (patch)
tree3a4c57b75bff7a34345bb7a68e24b0cf64b019d5
parentb3a895b052ff6849b73eaf106b7e475cefb8e35a (diff)
downloadstalld-840a2b3277fe3ea6348da6f060979ac80577bb03.tar.gz
src/utils: Die with a divizion by zero if verbose
Useful to get the stack with GDB. Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
-rw-r--r--src/utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 7a60f88..d3fbc7a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -149,6 +149,7 @@ int setup_signal_handling(void)
*/
void die(const char *fmt, ...)
{
+ volatile int zero = 0;
va_list ap;
int ret = errno;
@@ -163,6 +164,13 @@ void die(const char *fmt, ...)
va_end(ap);
fprintf(stderr, "\n");
+
+ /*
+ * Die with a divizion by zero to keep the stack on GDB.
+ */
+ if (config_verbose)
+ zero = 10 / zero;
+
exit(ret);
}