diff --git a/src/cgproxyd.hpp b/src/cgproxyd.hpp index d36b006..cc6abc2 100644 --- a/src/cgproxyd.hpp +++ b/src/cgproxyd.hpp @@ -188,8 +188,12 @@ class cgproxyd { thread th(SOCKET::startThread, handle_msg_static, move(status)); socketserver_thread = move(th); - status_f.wait(); - info("socketserver thread started"); + future_status fstatus=status_f.wait_for(chrono::seconds(THREAD_TIMEOUT)); + if (fstatus == std::future_status::ready) { + info("socketserver thread started"); + }else{ + error("socketserver thread timeout, maybe failed"); + } } void startExecsnoopThread() { @@ -203,8 +207,12 @@ class cgproxyd { thread th(EXECSNOOP::_startThread, handle_pid_static, move(status)); execsnoop_thread = move(th); - status_f.wait(); - info("execsnoop thread started"); + future_status fstatus=status_f.wait_for(chrono::seconds(THREAD_TIMEOUT)); + if (fstatus == std::future_status::ready) { + info("execsnoop thread started"); + }else{ + error("execsnoop thread timeout, maybe failed"); + } } void processRunningProgram() { diff --git a/src/common.h b/src/common.h index ac2c01b..cf18383 100644 --- a/src/common.h +++ b/src/common.h @@ -20,7 +20,7 @@ using namespace std; #define CGROUP_PROXY_PRESVERED "/proxy.slice" #define CGROUP_NOPROXY_PRESVERED "/noproxy.slice" -#define THREAD_UNDEF 0 +#define THREAD_TIMEOUT 5 #define MSG_TYPE_CONFIG_JSON 1 #define MSG_TYPE_CONFIG_PATH 2