diff options
author | Duncan Coutts <duncan@well-typed.com> | 2011-11-21 11:32:15 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2011-11-22 20:06:48 +0000 |
commit | cffb7601d8fa4c4939a08763564dda239fc80dab (patch) | |
tree | 3a5f9496fa631d007a45fec043475d13756c5d60 /rts/eventlog | |
parent | 7b594a5d7ac29972db39228e9c8b7f384313f39b (diff) | |
download | haskell-cffb7601d8fa4c4939a08763564dda239fc80dab.tar.gz |
Drop ".exe" exetention from eventlog file name
Fixes ticket #5472
Diffstat (limited to 'rts/eventlog')
-rw-r--r-- | rts/eventlog/EventLog.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 9547e7c788..2e2209d2d3 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -196,8 +196,22 @@ initEventLogging(void) { StgWord8 t, c; nat n_caps; + char *prog; - event_log_filename = stgMallocBytes(strlen(prog_name) + prog = stgMallocBytes(strlen(prog_name) + 1, "initEventLogging"); + strcpy(prog, prog_name); +#ifdef mingw32_HOST_OS + // on Windows, drop the .exe suffix if there is one + { + char *suff; + suff = strrchr(prog,'.'); + if (suff != NULL && !strcmp(suff,".exe")) { + *suff = '\0'; + } + } +#endif + + event_log_filename = stgMallocBytes(strlen(prog) + 10 /* .%d */ + 10 /* .eventlog */, "initEventLogging"); @@ -208,14 +222,15 @@ initEventLogging(void) if (event_log_pid == -1) { // #4512 // Single process - sprintf(event_log_filename, "%s.eventlog", prog_name); + sprintf(event_log_filename, "%s.eventlog", prog); event_log_pid = getpid(); } else { // Forked process, eventlog already started by the parent // before fork event_log_pid = getpid(); - sprintf(event_log_filename, "%s.%d.eventlog", prog_name, event_log_pid); + sprintf(event_log_filename, "%s.%d.eventlog", prog, event_log_pid); } + stgFree(prog); /* Open event log file for writing. */ if ((event_log_file = fopen(event_log_filename, "wb")) == NULL) { |