Skip to content

Commit 6e4580a

Browse files
committed
[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
1 parent 65a515b commit 6e4580a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/AST/PluginRegistry.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ LoadedExecutablePlugin::PluginProcess::~PluginProcess() {
214214
close(input);
215215
close(output);
216216
#endif
217-
llvm::sys::Wait(process, /*SecondsToWait=*/0);
217+
218+
// Set `SecondsToWait` non-zero so it waits for the timeout and kill it after
219+
// that. Usually when the pipe is closed above, the plugin detects the EOF in
220+
// the stdin and exits immediately, so this usually doesn't wait for the
221+
// timeout. Note that we can't use '0' because it performs a non-blocking
222+
// wait, which make the plugin a zombie if it hasn't exited.
223+
llvm::sys::Wait(process, /*SecondsToWait=*/1);
218224
}
219225

220226
ssize_t LoadedExecutablePlugin::PluginProcess::read(void *buf,

0 commit comments

Comments
 (0)