Author Topic: Suggestion: Exit from '.xsession' when X server fails to start  (Read 2353 times)

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
If the X server fails to start the subsequent execution of 'hsetroot' will end up in a segmentation fault. This is IMHO not ideal as the failure is conveyed more as a side effect and not directly checked.

As I've fallen myself now a few times into the "trap" and wrongly assumed this to be a segmentation fault of the X server itself, I'd like to suggest an additional "protection" in '~/.xsession' (or rather more correctly: '/etc/skel/.xsession') by replacing the single line 'waitforX' with:
Code: (bash) [Select]
X_PID=$!
waitforX
busybox ps -o pid | grep -q "^ *${X_PID}$" || ! echo no X server || exit
« Last Edit: August 26, 2011, 08:41:58 PM by maro »

Online curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10990
Re: Suggestion: Exit from '.xsession' when X server fails to start
« Reply #1 on: August 26, 2011, 11:56:53 PM »
In such a case, waitforX should print an error message and return 1 (unless the X server actually started and worked for a while).
The only barriers that can stop you are the ones you create yourself.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Suggestion: Exit from '.xsession' when X server fails to start
« Reply #2 on: August 27, 2011, 12:26:11 AM »
Good point, but it does not work for the test case that triggered me to write this (i.e. testing TC 4.0a1 in a QEMU VM with KQEMU enabled, where 'Xvesa' fails with an 'Illegal Instruction').

I've now an even shorter suggestion to achieve the same:
Code: (bash) [Select]
waitforX || ! echo failed in waitforX || exit