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?
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.
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:
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.
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.
This looks quite promising if you only have one child process:
xvfb-run sleep 60 &
pid_xvfb=$!
kill $(ps -o pid= --ppid $pid_xvfb)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With