summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Rubiolo2012-07-02 12:23:51 (EDT)
committer Eugene Tarassov2012-07-03 19:02:31 (EDT)
commit219157000832ba8201a6043abe79591480aa0eda (patch)
treeb3e8ea700a121aa6680012fe2f17ea33266f514a
parent9e177ad8fbea1767bcd722581b5c788b8f09bea2 (diff)
downloadorg.eclipse.tcf.agent-219157000832ba8201a6043abe79591480aa0eda.zip
org.eclipse.tcf.agent-219157000832ba8201a6043abe79591480aa0eda.tar.gz
org.eclipse.tcf.agent-219157000832ba8201a6043abe79591480aa0eda.tar.bz2
Fix collision between log name and daemon options
We now error out when a log name is specified at the same time as the daemon mode option. We only allow stderr as the logging channel in this case.
-rw-r--r--agent/tcf/framework/trace.c2
-rw-r--r--agent/tcf/framework/trace.h2
-rw-r--r--agent/tcf/main/main.c8
3 files changed, 10 insertions, 2 deletions
diff --git a/agent/tcf/framework/trace.c b/agent/tcf/framework/trace.c
index 5cc0dcd..bd08328 100644
--- a/agent/tcf/framework/trace.c
+++ b/agent/tcf/framework/trace.c
@@ -169,7 +169,7 @@ void open_log_file(const char * log_name) {
if (log_name == NULL) {
log_file = NULL;
}
- else if (strcmp(log_name, "-") == 0) {
+ else if (strcmp(log_name, LOG_NAME_STDERR) == 0) {
log_file = stderr;
}
else if ((log_file = fopen(log_name, "a")) == NULL) {
diff --git a/agent/tcf/framework/trace.h b/agent/tcf/framework/trace.h
index 3e787a1..9cddd35 100644
--- a/agent/tcf/framework/trace.h
+++ b/agent/tcf/framework/trace.h
@@ -41,6 +41,8 @@
#define LOG_STACK 0x2000
#define LOG_PLUGIN 0x4000
+#define LOG_NAME_STDERR "-"
+
extern int log_mode;
#if ENABLE_Trace
diff --git a/agent/tcf/main/main.c b/agent/tcf/main/main.c
index ec363f7..b2c83f8 100644
--- a/agent/tcf/main/main.c
+++ b/agent/tcf/main/main.c
@@ -117,7 +117,7 @@ static BOOL CtrlHandler(DWORD ctrl) {
static const char * help_text[] = {
"Usage: agent [OPTION]...",
"Start Target Communication Framework agent.",
- " -d run in daemon mode",
+ " -d run in daemon mode (output is sent to system logger)",
#if ENABLE_Cmdline
" -i run in interactive mode",
#endif
@@ -274,6 +274,12 @@ int main(int argc, char ** argv) {
}
}
+ if (daemon && strcmp (log_name, LOG_NAME_STDERR) != 0 && log_name != NULL) {
+ fprintf(stderr, "%s: error: can only log to stderr when in daemon "
+ "mode.\n", progname);
+ exit (1);
+ }
+
if (daemon) become_daemon();
open_log_file(log_name);