Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
#!/usr/bin/env python3
# flock(1) for macOS, as much of util-linux's as xl uses: flock [-n] [-w SECS] FILE COMMAND...,
# flock [-n] FD (the lock is on the open file description, which the shell keeps open), flock [-n] FILE -c CMD
import fcntl, os, subprocess, sys, time
args = sys.argv[1:]
nonblock = False; wait = None
while args and args[0].startswith('-'):
a = args.pop(0)
if a in ('-n', '--nonblock', '--nb'): nonblock = True
elif a in ('-w', '--wait', '--timeout'): wait = float(args.pop(0))
elif a in ('-x', '--exclusive', '-e'): pass
elif a in ('-s', '--shared'): pass
else: sys.exit('flock: unknown option ' + a)
if not args: sys.exit('flock: usage: flock [-n] [-w secs] FILE|FD [command...]')
target = args.pop(0)
if target.isdigit() and not args:
fd = int(target)
else:
fd = os.open(target, os.O_RDONLY | os.O_CREAT, 0o644)
deadline = None if wait is None else time.time() + wait
while True:
try:
fcntl.flock(fd, fcntl.LOCK_EX | (fcntl.LOCK_NB if (nonblock or deadline is not None) else 0))
break
except OSError:
if nonblock or (deadline is not None and time.time() >= deadline): sys.exit(1)
time.sleep(0.1)
if not args: sys.exit(0)
sys.exit(subprocess.call(args))