[Macros] Ensure to kill and reap plugin process

`llvm::sys::Wait(process, /*SecondsToWait=*/0)` perform a non-blocking
`wait`. That means the plugin goes a zombie if it hasn't exited.
Set `SecondsToWait` 1  so it wait for 1 second and kill it on the time
out. Usually, when the pipe is closed, the plugins detect the EOF in
stdin and exits immediately, fo the parent process usually don't wait
for the timeout.

rdar://148110944
This commit is contained in:
Rintaro Ishizaki
2025-03-31 10:22:10 -07:00
parent 65a515b2d4
commit 6e4580a862

View File

@@ -214,7 +214,13 @@ LoadedExecutablePlugin::PluginProcess::~PluginProcess() {
close(input);
close(output);
#endif
llvm::sys::Wait(process, /*SecondsToWait=*/0);
// Set `SecondsToWait` non-zero so it waits for the timeout and kill it after
// that. Usually when the pipe is closed above, the plugin detects the EOF in
// the stdin and exits immediately, so this usually doesn't wait for the
// timeout. Note that we can't use '0' because it performs a non-blocking
// wait, which make the plugin a zombie if it hasn't exited.
llvm::sys::Wait(process, /*SecondsToWait=*/1);
}
ssize_t LoadedExecutablePlugin::PluginProcess::read(void *buf,