From debd4603698c9219db4106e0c0c4e71d0efb604c Mon Sep 17 00:00:00 2001 From: Nikita Shubin Date: Fri, 23 Aug 2019 11:15:18 +0300 Subject: [PATCH] usertable: change system to execl call The man page for system states clear - execl is called AFTER fork, usertable for root is calling system after fork so we have fork, fork which is clearly not is expected couse the forked proccess doesn't exit. This result into many instances of incrond which state is uknown. Let's just call execl("/bin/sh", "sh", "-c", command, (char *) NULL); as per manual as we have forked before this call. --- usertable.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/usertable.cpp b/usertable.cpp index 11fd04b..fd26756 100644 --- a/usertable.cpp +++ b/usertable.cpp @@ -471,11 +471,9 @@ void UserTable::OnEvent(InotifyEvent& rEvt) // for system table if (m_fSysTable) { - if (system(cmd.c_str()) != 0) // exec failed - { - syslog(LOG_ERR, "cannot exec process: %s", strerror(errno)); - _exit(1); - } + execl("/bin/sh", "sh", "-c", cmd.c_str(), (char *) NULL); + syslog(LOG_ERR, "cannot exec process: %s", strerror(errno)); + _exit(1); } else { // for user table