summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2011-05-29 09:56:28 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-11-24 21:16:05 +0100
commit70ce8e3bb691d6533aef93a1ec300a8cfbd018d8 (patch)
treeeab59944f0c8d415b691369bd861274a7f818151
parent7130717658fe95ccf5c72b0fa2ab605ab3de9080 (diff)
downloadlatrace-70ce8e3bb691d6533aef93a1ec300a8cfbd018d8.tar.gz
latrace-70ce8e3bb691d6533aef93a1ec300a8cfbd018d8.tar.xz
latrace-70ce8e3bb691d6533aef93a1ec300a8cfbd018d8.zip
output: print the status info to a FILE
Added code to print the status info to the FILE, It'll be needed for error simulation, which is comming in shortly.
-rw-r--r--ChangeLog1
-rw-r--r--src/config.c1
-rw-r--r--src/config.h8
-rw-r--r--src/run.c8
4 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 27784d6..62f05e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 { \
diff --git a/src/run.c b/src/run.c
index a6891c5..f72cc7c 100644
--- a/src/run.c
+++ b/src/run.c
@@ -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);