diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/config.c | 1 | ||||
-rw-r--r-- | src/config.h | 8 | ||||
-rw-r--r-- | src/run.c | 8 |
4 files changed, 15 insertions, 3 deletions
@@ -39,6 +39,7 @@ latrace 0.5.11 * reading the -N config file immediatelly within args processing * adding support for simple text output + * print the status info to a FILE 2011-05-25 Jiri Olsa <olsajiri@gmail.com> * adding SIGTERM/SIGINT handlers, diff --git a/src/config.c b/src/config.c index 8405901..a7f588f 100644 --- a/src/config.c +++ b/src/config.c @@ -437,6 +437,7 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) lt_sh(cfg, args_maxlen) = LR_ARGS_MAXLEN; lt_sh(cfg, args_detail_maxlen) = LR_ARGS_DETAIL_MAXLEN; cfg->csort = LT_CSORT_CALL; + cfg->fstat = stdout; cfg->output_tty_fd = -1; /* read the default config file first */ diff --git a/src/config.h b/src/config.h index 8cb2b0a..cf9c64c 100644 --- a/src/config.h +++ b/src/config.h @@ -173,6 +173,7 @@ struct lt_config_app { char *arg[LT_NUM_ARG]; int arg_num; + FILE *fstat; int csort; int output_tty; @@ -422,6 +423,13 @@ do { \ PRINT(fmt, ## args); \ } while(0) +#define PRINT_STATUS(cfg, fmt, args...) \ +do { \ + if (!(cfg)->fstat) \ + break; \ + fprintf((cfg)->fstat, fmt, args); \ + fflush(NULL); \ +} while(0) #define BUG() \ do { \ @@ -486,12 +486,14 @@ int lt_run(struct lt_config_app *cfg) status = kill_child(cfg, &pa); } - printf("\n%s finished - ", cfg->prog); + PRINT_STATUS(cfg, "\n%s finished - ", cfg->prog); if (WIFEXITED(status)) { - printf("exited, status=%d\n", WEXITSTATUS(status)); + PRINT_STATUS(cfg, "exited, status=%d\n", + WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { - printf("killed by signal %d\n", WTERMSIG(status)); + PRINT_STATUS(cfg, "killed by signal %d\n", + WTERMSIG(status)); } ret = WEXITSTATUS(status); |