diff options
| author | user <user@clank> | 2026-09-22 13:08:49 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-22 13:08:49 +0200 |
| commit | c9f61fc15c99e0317ca603be4999bedf57a53f50 (patch) | |
| tree | a65690645193ae251c1ef652b10f9a253db54b96 | |
| parent | demo: boot the SL0PBOY-forked BIOS in the README gif (diff) | |
| download | gbos-c9f61fc15c99e0317ca603be4999bedf57a53f50.tar.gz gbos-c9f61fc15c99e0317ca603be4999bedf57a53f50.tar.xz gbos-c9f61fc15c99e0317ca603be4999bedf57a53f50.zip | |
sh: background dhcp at boot so the prompt is never blocked
dhcp's recv times out only after ~250*65536 pumps x3 retries, so
fork()+wait() left the screen stuck at 'dhcp: discovering' with no
prompt whenever no DHCP server answered (raw emulator, no bridge).
Fork without waiting: the prompt is immediate, the lease (or 'no
offer') lands a moment later, and the job is reaped by the main loop.
| -rw-r--r-- | usr/sh.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -155,11 +155,14 @@ void main(void) { char *tok[16]; char cwd[40]; cwd[0] = '/'; cwd[1] = 0; - /* bring up networking first: run the DHCP client and wait for it to finish - (got a lease, or gave up). Only then drop to the prompt. */ + /* bring up networking in the BACKGROUND: dhcp's recv blocks a long time when + no server answers, and wait()ing on it would leave the screen stuck at + "dhcp: discovering" with no prompt. Fork without waiting so the prompt is + immediate; the lease (or "no offer") lands a moment later and the job is + reaped by the loop below. */ { unsigned char d = lookup("dhcp"); - if (d != NOFD) { if (fork() == 0) exec(d); else wait(); } + if (d != NOFD && fork() == 0) exec(d); } for (;;) { unsigned char nt, i, pipepos, c, bg; |
