Skip to content

Commit 4556e59

Browse files
committed
improve machine process startup error reporting
was swallowed before due to unlucky timing
1 parent 11ae590 commit 4556e59

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

machine/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ where
260260
{
261261
thread::spawn(move || {
262262
let ns = Namespace::unshare()?;
263-
let _ = ns_tx.send(ns);
264263

265264
let res = async_global_executor::block_on(async move {
266265
let iface = iface::Iface::new()?;
@@ -335,7 +334,10 @@ where
335334
bin.stdin(Stdio::piped())
336335
.stdout(Stdio::piped())
337336
.stderr(Stdio::piped());
338-
let mut child = bin.spawn()?;
337+
let mut child = bin.spawn().map_err(|e| {
338+
log::error!("cannot start machine {:?}: {}", bin, e);
339+
e
340+
})?;
339341
let mut stdout = BufReader::new(child.stdout.take().unwrap()).lines().fuse();
340342
let mut stderr = BufReader::new(child.stderr.take().unwrap()).lines().fuse();
341343
let mut stdin = child.stdin.take().unwrap();
@@ -387,6 +389,9 @@ where
387389
.fuse();
388390
futures::pin_mut!(stderr_task);
389391

392+
// unblock here so that possible exec error has a chance to get out
393+
let _ = ns_tx.send(ns);
394+
390395
futures::select! {
391396
res = ctrl_task => res?,
392397
res = reader_task => res?,

0 commit comments

Comments
 (0)