Skip to content

UXBoot

#import "UXBoot.xc" // tests only; not reachable through #use <UXKit>

On the board, init(1) runs the boot scripts off the SD card, and one of them starts gemd with &.

Under qemu the SD card is not mounted. /bin/sh is missing, init runs no scripts, and nothing starts the window server. libGEM then hard-exits with “no window server”. That is correct: there is no single-process mode, and pretending otherwise would be worse than the error.

A test running under qemu therefore has to start gemd itself. That is all this class does.

Starting the window server from a client is the “the desktop is not the server” mistake in miniature.

An application is a client. It connects to a service that something else is responsible for running. An application that starts its own server has taken the role of the system, and when two applications run, the second finds a server it did not start and does not own.

The file exists in one place, is imported by nothing that ships, and says so in its first line. The scaffolding is allowed to exist because this containment stops it from leaking.

static bool ensureWindowServer(void)
  1. Try to connect to the gem service. If it is already up (as on the board), return immediately. The common case costs one connect.
  2. Otherwise sys_spawn("/bin/gemd").
  3. Wait for it to register, retrying with a sleep, for up to 5 seconds.

Returns false if the spawn failed or the server never registered, so a test can report “no window server” instead of proceeding into a crash.