Skip to content

Fixed invoke_command to support resources with more than 64 char output #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dsc_lib/src/dscresources/command_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,21 @@ pub fn invoke_command(executable: &str, args: Option<Vec<String>>, input: Option
child_stdin.write_all(input.unwrap_or_default().as_bytes())?;
child_stdin.flush()?;
}
let exit_status = child.wait()?;

let Some(mut child_stdout) = child.stdout.take() else {
return Err(DscError::CommandOperation("Failed to open stdout".to_string(), executable.to_string()));
};
let mut stdout_buf = Vec::new();
child_stdout.read_to_end(&mut stdout_buf)?;

let Some(mut child_stderr) = child.stderr.take() else {
return Err(DscError::CommandOperation("Failed to open stderr".to_string(), executable.to_string()));
};
let mut stdout_buf = Vec::new();
child_stdout.read_to_end(&mut stdout_buf)?;
let mut stderr_buf = Vec::new();
child_stderr.read_to_end(&mut stderr_buf)?;

let exit_status = child.wait()?;

let exit_code = exit_status.code().unwrap_or(EXIT_PROCESS_TERMINATED);
let stdout = String::from_utf8_lossy(&stdout_buf).to_string();
let stderr = String::from_utf8_lossy(&stderr_buf).to_string();
Expand Down