diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-16 19:31:20 -0800 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-02-16 19:31:20 -0800 |
commit | a5d231b6a60a4ab868918850be24640e88843825 (patch) | |
tree | 4943e719f84374c7245707998d2297997fcd56cb /src/map/map.cpp | |
parent | b17b9021ecf9b16c265d0a6b60faa761b34eae35 (diff) | |
download | tmwa-a5d231b6a60a4ab868918850be24640e88843825.tar.gz tmwa-a5d231b6a60a4ab868918850be24640e88843825.tar.bz2 tmwa-a5d231b6a60a4ab868918850be24640e88843825.tar.xz tmwa-a5d231b6a60a4ab868918850be24640e88843825.zip |
Rotate logs in background
Also reenable the critical bonus effect.
Diffstat (limited to 'src/map/map.cpp')
-rw-r--r-- | src/map/map.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index 6ed7662..d7cf4f6 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1,8 +1,10 @@ #include "map.hpp" #include <sys/time.h> +#include <sys/wait.h> #include <netdb.h> +#include <unistd.h> #include <cstdlib> #include <cstring> @@ -1612,15 +1614,24 @@ void map_close_logfile(void) { if (map_logfile) { - std::string filenameop_buf = STRPRINTF( - "gzip -f %s.%ld", - map_logfile_name, - map_logfile_index); + std::string filename = STRPRINTF("%s.%ld", map_logfile_name, map_logfile_index); + const char *args[] = + { + "gzip", + "-f", + filename.c_str(), + NULL + }; + char **argv = const_cast<char **>(args); fclose(map_logfile); - if (!system(filenameop_buf.c_str())) - perror(filenameop_buf.c_str()); + if (!fork()) + { + execvp("gzip", argv); + _exit(1); + } + wait(NULL); } } |