Fix restart missing arguments in proc-macro-srv

This commit is contained in:
Edwin Cheng 2020-04-21 04:57:55 +08:00
parent 0ad6b6d407
commit bd350108b0

View file

@ -9,7 +9,7 @@ use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTas
use io::{BufRead, BufReader}; use io::{BufRead, BufReader};
use std::{ use std::{
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
ffi::OsStr, ffi::{OsStr, OsString},
io::{self, Write}, io::{self, Write},
path::{Path, PathBuf}, path::{Path, PathBuf},
process::{Child, Command, Stdio}, process::{Child, Command, Stdio},
@ -35,6 +35,7 @@ struct Task {
struct Process { struct Process {
path: PathBuf, path: PathBuf,
args: Vec<OsString>,
child: Child, child: Child,
} }
@ -46,22 +47,25 @@ impl Drop for Process {
impl Process { impl Process {
fn run( fn run(
process_path: PathBuf, path: PathBuf,
args: impl IntoIterator<Item = impl AsRef<OsStr>>, args: impl IntoIterator<Item = impl AsRef<OsStr>>,
) -> io::Result<Process> { ) -> io::Result<Process> {
let child = Command::new(&process_path) let args = args.into_iter().map(|s| s.as_ref().into()).collect();
.args(args)
let child = Command::new(&path)
.args(&args)
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::null()) .stderr(Stdio::null())
.spawn()?; .spawn()?;
Ok(Process { path: process_path, child }) Ok(Process { path, args, child })
} }
fn restart(&mut self) -> io::Result<()> { fn restart(&mut self) -> io::Result<()> {
let _ = self.child.kill(); let _ = self.child.kill();
self.child = Command::new(&self.path) self.child = Command::new(&self.path)
.args(&self.args)
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::null()) .stderr(Stdio::null())