[Toybox] Some questions re: init...
ibid.ag at gmail.com
ibid.ag at gmail.com
Wed Jan 1 01:26:24 PST 2014
I was looking over init, and noticed some things that seemed possibly
less than optimal, as well as one detail that seemed illogical.
First, the oddity:
p = getenv("TERM");
#ifdef VT_OPENQRY
int terminal_no;
if (ioctl(0, VT_OPENQRY, &terminal_no)) {
if (!p || !strcmp(p,"linux")) putenv((char*)"TERM=vt102");
} else
#endif
if (!p) putenv((char*)"TERM=linux");
As I read it, this code will set TERM to vt102 if
(1) the VT_OPENQRY ioctl is supported, AND
(2) TERM is not set or is set to "linux".
This ioctl returns 1 to MAX_NR_CONSOLES or -1, so
if (ioctl(0, VT_OPENQRY, ...))
will ALWAYS be true since (-1) is still nonzero.
But I don't see why "is another tty available" should change the
environment of the one tty.
I see no point to this oddity, especially given the common use of
"TERM=linux".
Deleting this would lose the one #ifdef.
Second, I note that init.c uses a number of x* functions and calls
error_exit() in some cases...
These could panic the system on failure.
-x*alloc/xstrdup/xmsprintf (lines 119-121, 153-155, 169) in the inittab
parsing is justifable; if malloc fails before init starts anything,
there's no way we're running anything.
-final_run will panic if fork()/vfork() fails (line 236).
-Do we need to exit on failure to write informational messages?
I'm thinking of lines 55 (failure to open console) and 439 ("started
init" message).
Thanks,
Isaac Dunham
1388568384.0
More information about the Toybox
mailing list