mirror of
https://github.com/polybar/polybar.git
synced 2026-03-12 19:25:26 +00:00
fix(process): fork_detached created zombie processes
Since the forked processes are still our children, we need to wait on them, otherwise they become zombie processes. We now fork twice, let the first fork immediately return and wait on it. This reparents the second fork, which runs the actual code, to the init process which then collects it. Ref #770
This commit is contained in:
committed by
Patrick Ziegler
parent
ccf14d9816
commit
47483a94f1
@ -33,7 +33,7 @@ command<output_policy::IGNORED>::~command() {
|
||||
* Execute the command
|
||||
*/
|
||||
int command<output_policy::IGNORED>::exec(bool wait_for_completion) {
|
||||
m_forkpid = process_util::fork_detached([m_cmd = m_cmd] { process_util::exec_sh(m_cmd.c_str()); });
|
||||
m_forkpid = process_util::spawn_async([m_cmd = m_cmd] { process_util::exec_sh(m_cmd.c_str()); });
|
||||
if (wait_for_completion) {
|
||||
auto status = wait();
|
||||
m_forkpid = -1;
|
||||
|
||||
Reference in New Issue
Block a user