custom: reap zombie processes on termination

This commit is contained in:
André Silva 2023-11-02 01:57:55 +00:00
parent 121dcc645f
commit 1c1a39f597
No known key found for this signature in database
GPG Key ID: 7C34FA12A023DC55
1 changed files with 4 additions and 0 deletions

View File

@ -112,6 +112,10 @@ inline FILE* open(const std::string& cmd, int& pid) {
execlp("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0); execlp("/bin/sh", "sh", "-c", cmd.c_str(), (char*)0);
exit(0); exit(0);
} else { } else {
reap_mtx.lock();
reap.push_back(child_pid);
reap_mtx.unlock();
::close(fd[1]); ::close(fd[1]);
} }
pid = child_pid; pid = child_pid;