Skip to content

Commit 07bb353

Browse files
authored
Merge pull request swiftlang#80413 from rintaro/macros-plugin-wait1
[Macros] Ensure to kill and reap plugin process
2 parents 9694cc8 + 6e4580a commit 07bb353

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)