chiark / gitweb /
keepalive Xfvb
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Dec 2020 23:18:19 +0000 (23:18 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Dec 2020 23:19:22 +0000 (23:19 +0000)
We need -terminate because Xserver becomes its own pg or something.

Like this it fails, though, I think because the mere TCP connection
doesn't count.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver.rs
wdriver/wdt-simple.rs

index ce0aa696bb74a46505e96c2b3d769821b06dfd2d..791512ebed5d7ff35a6524974b4f9baf29a84ca5 100644 (file)
@@ -10,6 +10,7 @@ pub use void::Void;
 pub use std::env;
 pub use std::fs;
 pub use std::io::{BufRead, BufReader, ErrorKind, Write};
+pub use std::net::TcpStream;
 pub use std::os::unix::process::CommandExt;
 pub use std::os::unix::fs::DirBuilderExt;
 pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode??
@@ -105,14 +106,14 @@ fn prepare_tmpdir(opts: &Opts, current_exe: &str) -> String {
 
 #[throws(AE)]
 fn prepare_xserver() {
-  const DISPLAY : &str = "12";
+  const DISPLAY : u16 = 12;
 
   let mut xcmd = Command::new("Xvfb");
   xcmd
     .args("-nolisten unix \
            -nolisten local \
            -listen inet6 \
-           -noreset \
+           -terminate \
            -displayfd 1".split(' '))
     .arg(format!(":{}", DISPLAY))
     .stdout(Stdio::piped());
@@ -128,7 +129,7 @@ fn prepare_xserver() {
   }
 
   match l {
-    Some(Ok(l)) if l == DISPLAY => { l },
+    Some(Ok(l)) if l == DISPLAY.to_string() => { l },
     Some(Ok(l)) => throw!(anyhow!(
       "Xfvb said {:?}, expected {:?}",
       l, DISPLAY
@@ -138,7 +139,11 @@ fn prepare_xserver() {
   };
 
   env::set_var("DISPLAY", format!("[::1]:{}", DISPLAY));
-  
+
+  let stream = TcpStream::connect(("::1", DISPLAY+6000))
+    .context("make keepalive connection to X server")?;
+
+  Box::leak(Box::new(stream));
 }
 
 #[throws(AE)]
index 8c663e102a02c4c5fc6fb917be418efc33c0d169..d3eca3312942a8ac9eec33bf761292c9c998b99c 100644 (file)
@@ -10,9 +10,13 @@ fn main(){
 
   println!("hi! {:#?}", &s);
 
-  let mut c = Command::new("xdpyinfo");
-  let s = c
-    .spawn().context("spawn")?
-    .wait().context("wait")?;
-  println!("s = {:?}", &s);
+  for _ in 0..2 {
+    let mut c = Command::new("xdpyinfo");
+    let s = c
+      .spawn().context("spawn")?
+      .wait().context("wait")?;
+    println!("s = {:?}", &s);
+
+    std::thread::sleep_ms(500);
+  }
 }