aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <egil@erlang.org>2012-10-10 15:09:30 +0200
committerBjörn-Egil Dahlberg <egil@erlang.org>2012-10-15 20:49:44 +0200
commit70c9312c4bd8832c31094dd076364077f0a684c5 (patch)
tree52177c8fa5a45926fc2810897fb3c5abf1680fbd /erts
parent6aa87d58b756ef65650ee793ad4ece8add7b70fb (diff)
downloadotp-70c9312c4bd8832c31094dd076364077f0a684c5.tar.gz
otp-70c9312c4bd8832c31094dd076364077f0a684c5.tar.bz2
otp-70c9312c4bd8832c31094dd076364077f0a684c5.zip
heart: Refactor heart debugging
Diffstat (limited to 'erts')
-rw-r--r--erts/etc/common/heart.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c
index c6ce017d8c..dcb83c33ac 100644
--- a/erts/etc/common/heart.c
+++ b/erts/etc/common/heart.c
@@ -352,12 +352,14 @@ static void get_arguments(int argc, char** argv) {
debugf("arguments -ht %d -wt %d -pid %lu\n",h,w,p);
}
-int
-main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
+
+ if (is_env_set("HEART_DEBUG")) {
+ fprintf(stderr, "heart: debug is ON!\r\n");
+ debug_on = 1;
+ }
+
get_arguments(argc,argv);
- if (is_env_set("HEART_DEBUG"))
- debug_on=1;
#ifdef __WIN32__
if (debug_on) {
if(!is_env_set("ERLSRV_SERVICE_NAME")) {
@@ -649,6 +651,7 @@ do_terminate(int erlin_fd, int reason) {
to call wd_reset().
*/
struct msg message;
+ int ret = 0;
switch (reason) {
case R_SHUT_DOWN:
@@ -656,6 +659,7 @@ do_terminate(int erlin_fd, int reason) {
case R_CRASHING:
print_error("Waiting for dump");
read_message(erlin_fd, &message); /* read until we get something */
+ /* fall through */
case R_TIMEOUT:
case R_CLOSED:
case R_ERROR:
@@ -689,15 +693,15 @@ do_terminate(int erlin_fd, int reason) {
else {
kill_old_erlang();
/* suppress gcc warning with 'if' */
- if(system(command));
- print_error("Executed \"%s\". Terminating.",command);
+ ret = system(command);
+ print_error("Executed \"%s\" -> %d. Terminating.",command, ret);
}
free_env_val(command);
} else {
kill_old_erlang();
/* suppress gcc warning with 'if' */
- if(system((char*)&cmd[0]));
- print_error("Executed \"%s\". Terminating.",cmd);
+ ret = system((char*)&cmd[0]);
+ print_error("Executed \"%s\" -> %d. Terminating.",cmd, ret);
}
#endif
}
@@ -895,12 +899,13 @@ debugf(const char *format,...)
{
va_list args;
- if (!debug_on) return;
- va_start(args, format);
- fprintf(stderr, "Heart: ");
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\r\n");
+ if (debug_on) {
+ va_start(args, format);
+ fprintf(stderr, "Heart: ");
+ vfprintf(stderr, format, args);
+ va_end(args);
+ fprintf(stderr, "\r\n");
+ }
}
#ifdef __WIN32__