Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all processes in a display from Xvfb?

I have a program that is launching ChromeDrivers, which launches Chrome browsers + later attempts to close both after doing some task (using Selenium). But often times my program can't kill off the ChromeDriver/Chrome browser. When I try to kill the ChromeDriver the Chrome browser + all it's other child processes aren't killed off.

I have tried to look at /proc/x/environ to determine if I can extract the DISPLAY of the process, but found that no such environment variable was set for the browser + child processes.

Is there any other way to detect all processes in a specific Xvfb display and kill them all?

like image 639
Ben Avatar asked Dec 18 '15 21:12

Ben


People also ask

How does the process ID of Xvfb get stored?

The process ID of Xvfb is stored for later use. The specified command is then run using the X display corresponding to the Xvfb server just started and the X authority file created earlier.

How to set up Xvfb for remote control?

Then to setup access to Xvfb for remote control, you can use X11 over SSH or VNC over SSH, e.g. export DISPLAY=:1 Xvfb $DISPLAY -screen 0 1024x768x16 & fluxbox & x11vnc -display $DISPLAY -bg -forever -nopw -quiet -listen localhost -xkb Here is script friendly version to run Xvfb, x11vnc and fluxbox:

Is Xvfb a virtual server?

Alternatively, you could set up a proxy for VNC's port, eg ssh tunnel. @seanf I see a black screen instead of the browser. Can you please have a look at this issue? stackoverflow.com/questions/63935935/… It's virtual. From the man page Xvfb (1): Xvfb is an X server that can run on machines with no display hardware and no physical input devices.

What is xvfb-run and how to use it?

xvfb-run is a wrapper for the Xvfb (1x) command which simplifies the task of running commands (typically an X client, or a script containing a list of clients to be run) within a virtual X server environment.


1 Answers

This looks quite promising if you only have one child process:

xvfb-run sleep 60 &
pid_xvfb=$!
kill $(ps -o pid= --ppid $pid_xvfb)
like image 55
Matthias Avatar answered Oct 11 '22 16:10

Matthias