codebrainz / code-format

A code formatting plugin for Geany using ClangFormat.
GNU General Public License v2.0
12 stars 6 forks source link

Need to wait on clang-format child processes #7

Open codebrainz opened 6 years ago

codebrainz commented 6 years ago

Expected behaviour

No zombie processes.

Actual behaviour

Lots of them.

Steps to reproduce

Run for a while, zombies are not reaped.

vrbincs commented 2 years ago

On Linux, this is still reproducible and it appears to be a problem in the function fmt_process_close(); specifically this statement g_source_remove(proc->exit_handler).

The thing is that g_child_watch_add() functions like wait() or waitpid() and by removing the handler 'on_process_exited', the child process is never reaped.

On Windows, this is not a problem because g_spawn_close_pid() does its thing in fmt_process_close(), but not on Unix like systems. see https://developer.gimp.org/api/2.0/glib/glib-Spawning-Processes.html#g-spawn-close-pid

I am not entirely certain what fmt_process_close() should do considering there is already a watcher on the process. Perhaps forcing the process to stop (in case it hangs or some other reason)?