From af78ad201266e3aa0cb5d15b469b75d2b4787b55 Mon Sep 17 00:00:00 2001 From: springzfx Date: Fri, 29 May 2020 16:16:32 +0800 Subject: [PATCH] flush fprintf --- src/cgproxyd.hpp | 7 ++++--- src/common.h | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cgproxyd.hpp b/src/cgproxyd.hpp index 3e96e5d..417b115 100644 --- a/src/cgproxyd.hpp +++ b/src/cgproxyd.hpp @@ -44,7 +44,10 @@ bool loadExecsnoopLib() { } info("dlsym startThread success"); return true; - } catch (exception &e) { return false; } + } catch (exception &e) { + debug("exception: %s",e.what()); + return false; + } } } // namespace CGPROXY::EXECSNOOP @@ -253,7 +256,6 @@ public: execsnoop_thread_id = startExecsnoopThread(); if (execsnoop_thread_id > 0) info("execsnoop thread started"); } - cout << flush; pthread_join(socket_thread_id, NULL); pthread_join(execsnoop_thread_id, NULL); @@ -295,7 +297,6 @@ void processArgs(const int argc, char *argv[]) { } int main(int argc, char *argv[]) { - setbuf(stdout, NULL); processArgs(argc, argv); if (print_help) { print_usage(); diff --git a/src/common.h b/src/common.h index 6d94be5..ac2c01b 100644 --- a/src/common.h +++ b/src/common.h @@ -46,6 +46,7 @@ extern bool enable_info; fprintf(stderr, "error: "); \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ + fflush(stderr); \ } #define debug(...) \ @@ -53,6 +54,7 @@ extern bool enable_info; fprintf(stdout, "debug: "); \ fprintf(stdout, __VA_ARGS__); \ fprintf(stdout, "\n"); \ + fflush(stdout); \ } #define info(...) \ @@ -60,6 +62,7 @@ extern bool enable_info; fprintf(stdout, "info: "); \ fprintf(stdout, __VA_ARGS__); \ fprintf(stdout, "\n"); \ + fflush(stdout); \ } #define return_error return -1