I tried to contact the author but never got a response after a week.
If you need to kill the process that was instantiated, it will leave a "defunct" process behind. And if you have a repeating mechanism to use this process, you end up with a huge number of zombies. This can be fixed by changing the method kill as follows:
void exec_stream_t::kill()
{
if( m_impl->m_child_pid!=-1 ) {
if( ::kill( m_impl->m_child_pid, SIGKILL )==-1 ) {
throw os_error_t( "exec_stream_t::kill: kill failed" );
}
// The correct way to handle killing a child process is to wait for the OS
// to release the child process resources before assigning -1 to m_child_pid.
// Assigning -1 to m_child_pid without waiting will result in a "defunct" process
// (aka zombie process) remaining in the process table.
pid_t code=waitpid( m_impl->m_child_pid, &m_impl->m_exit_code, 0 );
if( code == m_impl->m_child_pid )
{
m_impl->m_child_pid=-1;
m_impl->m_exit_code=0;
}
else if( code == -1 )
{
throw os_error_t( "exec_stream_t::kill: waitpid failed" );
}
}
}