Skip to content
Snippets Groups Projects
Commit 0befd735 authored by Stephen D's avatar Stephen D
Browse files

fix zombie ssdv processes

parent 99030bb3
No related branches found
No related tags found
1 merge request!4Spi
use anyhow::{bail, Context}; use anyhow::{bail, Context};
use subprocess::{Popen, PopenConfig, Redirection};
use crate::packet::RawPacket; use crate::packet::RawPacket;
// TODO eventually rewrite Ssdv in Rust? // TODO eventually rewrite Ssdv in Rust?
// Don't want to use FFI because then segfaults can hurt us // Don't want to use FFI because then segfaults can hurt us
pub fn ssdv_encode(callsign: &str, img: &[u8], img_idx: u8) -> anyhow::Result<Vec<RawPacket>> { pub fn ssdv_encode(callsign: &str, img: &[u8], img_idx: u8) -> anyhow::Result<Vec<RawPacket>> {
let (stdout, stderr) = subprocess::Exec::cmd("ssdv") let mut p = Popen::create(
.args(&[ &[
"ssdv",
"-e", "-e",
"-c", "-c",
callsign, callsign,
...@@ -15,10 +17,16 @@ pub fn ssdv_encode(callsign: &str, img: &[u8], img_idx: u8) -> anyhow::Result<Ve ...@@ -15,10 +17,16 @@ pub fn ssdv_encode(callsign: &str, img: &[u8], img_idx: u8) -> anyhow::Result<Ve
"6", "6",
"-i", "-i",
&format!("{}", img_idx), &format!("{}", img_idx),
]) ],
.stdin(img.to_vec()) PopenConfig {
.communicate()? stdin: Redirection::Pipe,
.read()?; stdout: Redirection::Pipe,
stderr: Redirection::Pipe,
..Default::default()
},
)?;
let (stdout, stderr) = p.communicate_bytes(Some(img))?;
if let Some(stderr) = stderr { if let Some(stderr) = stderr {
if !stderr.is_empty() { if !stderr.is_empty() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment