mirror of
https://github.com/nushell/nushell
synced 2024-12-27 13:33:16 +00:00
Wait on the plugin child to prevent zombies (#901)
This commit is contained in:
parent
b1aa8f4edf
commit
96fedb47ee
1 changed files with 17 additions and 18 deletions
|
@ -92,28 +92,26 @@ impl Command for PluginDeclaration {
|
||||||
let reader = stdout_reader;
|
let reader = stdout_reader;
|
||||||
let mut buf_read = BufReader::with_capacity(OUTPUT_BUFFER_SIZE, reader);
|
let mut buf_read = BufReader::with_capacity(OUTPUT_BUFFER_SIZE, reader);
|
||||||
|
|
||||||
let response = self
|
let response = self.encoding.decode_response(&mut buf_read).map_err(|err| {
|
||||||
.encoding
|
|
||||||
.decode_response(&mut buf_read)
|
|
||||||
.map_err(|err| {
|
|
||||||
let decl = engine_state.get_decl(call.decl_id);
|
let decl = engine_state.get_decl(call.decl_id);
|
||||||
ShellError::SpannedLabeledError(
|
ShellError::SpannedLabeledError(
|
||||||
format!("Unable to decode call for {}", decl.name()),
|
format!("Unable to decode call for {}", decl.name()),
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
call.head,
|
call.head,
|
||||||
)
|
)
|
||||||
})?;
|
});
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
PluginResponse::Value(value) => {
|
Ok(PluginResponse::Value(value)) => {
|
||||||
Ok(PipelineData::Value(value.as_ref().clone(), None))
|
Ok(PipelineData::Value(value.as_ref().clone(), None))
|
||||||
}
|
}
|
||||||
PluginResponse::Error(err) => Err(err.into()),
|
Ok(PluginResponse::Error(err)) => Err(err.into()),
|
||||||
PluginResponse::Signature(..) => Err(ShellError::SpannedLabeledError(
|
Ok(PluginResponse::Signature(..)) => Err(ShellError::SpannedLabeledError(
|
||||||
"Plugin missing value".into(),
|
"Plugin missing value".into(),
|
||||||
"Received a signature from plugin instead of value".into(),
|
"Received a signature from plugin instead of value".into(),
|
||||||
call.head,
|
call.head,
|
||||||
)),
|
)),
|
||||||
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(ShellError::SpannedLabeledError(
|
Err(ShellError::SpannedLabeledError(
|
||||||
|
@ -121,11 +119,12 @@ impl Command for PluginDeclaration {
|
||||||
"no stdout reader".into(),
|
"no stdout reader".into(),
|
||||||
call.head,
|
call.head,
|
||||||
))
|
))
|
||||||
}?;
|
};
|
||||||
|
|
||||||
// There is no need to wait for the child process to finish
|
// We need to call .wait() on the child, or we'll risk summoning the zombie horde
|
||||||
// The response has been collected from the plugin call
|
let _ = child.wait();
|
||||||
Ok(pipeline_data)
|
|
||||||
|
pipeline_data
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_plugin(&self) -> Option<(&PathBuf, &str, &Option<PathBuf>)> {
|
fn is_plugin(&self) -> Option<(&PathBuf, &str, &Option<PathBuf>)> {
|
||||||
|
|
Loading…
Reference in a new issue