File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ echo "starting vnc"
12
12
-rfbport 5900 \
13
13
2> /tmp/x11vnc_stderr.log) &
14
14
15
+ x11vnc_pid=$!
16
+
15
17
# Wait for x11vnc to start
16
18
timeout=10
17
19
while [ $timeout -gt 0 ]; do
@@ -23,9 +25,25 @@ while [ $timeout -gt 0 ]; do
23
25
done
24
26
25
27
if [ $timeout -eq 0 ]; then
26
- echo " x11vnc stderr output:" >&2
28
+ echo " x11vnc failed to start, stderr output:" >&2
27
29
cat /tmp/x11vnc_stderr.log >&2
28
30
exit 1
29
31
fi
30
32
31
- rm /tmp/x11vnc_stderr.log
33
+ : > /tmp/x11vnc_stderr.log
34
+
35
+ # Monitor x11vnc process in the background
36
+ (
37
+ while true ; do
38
+ if ! kill -0 $x11vnc_pid 2> /dev/null; then
39
+ echo " x11vnc process crashed, restarting..." >&2
40
+ if [ -f /tmp/x11vnc_stderr.log ]; then
41
+ echo " x11vnc stderr output:" >&2
42
+ cat /tmp/x11vnc_stderr.log >&2
43
+ rm /tmp/x11vnc_stderr.log
44
+ fi
45
+ exec " $0 "
46
+ fi
47
+ sleep 5
48
+ done
49
+ ) &
You can’t perform that action at this time.
0 commit comments