OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
hyprland-config high occasional DISPUTE

Fix os.execute failing with 'no child processes' in a Lua Hyprland config

hyprlandomarchyarchnvidiaintelamdlaptopdesktop
AUDITED Audited against its sources and confirmed accurate.

Symptom

Conditional logic in a Lua Hyprland config never takes the branch it should. A shell probe that exits 0 when run manually reports failure from inside the config. Debugging shows os.execute("true") returning nil, "No child processes", 10. On Omarchy 4.0.0 the visible effect was that NVD_BACKEND, LIBVA_DRIVER_NAME and __GLX_VENDOR_LIBRARY_NAME were never set for NVIDIA GPUs.

Cause

Hyprland reaps or ignores SIGCHLD for its own children, so the wait() inside Lua's os.execute() can never find the process it just forked. os.execute() therefore always fails to retrieve an exit status (classic ECHILD) when called from Hyprland's Lua config context. Anything that shells out and branches on success is silently always-false. io.open() and io.popen() (reading output, not exit status) still work.

Fix

Do not branch on os.execute() exit status inside the config. Read the answer instead of testing it.

Read sysfs / files directly:


local function has_nvidia()
  local f = io.popen("lspci -nn 2>/dev/null")
  if not f then return false end
  local out = f:read("*a") or ""
  f:close()
  return out:match("NVIDIA") ~= nil
end

if has_nvidia() then
  hl.env("LIBVA_DRIVER_NAME", "nvidia")
  hl.env("__GLX_VENDOR_LIBRARY_NAME", "nvidia")
  hl.env("NVD_BACKEND", "direct")
end

Or have the script print a token and test the output:


local f = io.popen("my-detector && echo YES")
local ok = (f:read("*a") or ""):match("YES") ~= nil
f:close()

Confirm the env vars actually landed:


hyprctl dispatch 'hl.dsp.exec_cmd("env > /tmp/envtest.txt")'
grep -E 'NVD_BACKEND|LIBVA_DRIVER_NAME|__GLX_VENDOR_LIBRARY_NAME' /tmp/envtest.txt
systemctl --user show-environment | grep -E 'NVD_BACKEND|LIBVA_DRIVER_NAME'

On Omarchy, this specific bug is fixed in v4.0.1, so update rather than patching:


omarchy-update    # or: Update > Omarchy from the menu

Verify

grep NVD_BACKEND /tmp/envtest.txt (produced by the dispatch above) shows the value, and systemctl --user show-environment lists it after a full session restart.

Sources

lua-config-os-execute-no-child-processes