[Toybox] [PATCH] telnetd: don't exit if waitpid() returns 0.

enh enh at google.com
Thu Apr 22 19:43:11 PDT 2021


On Thu, Mar 18, 2021 at 7:26 PM Rob Landley <rob at landley.net> wrote:

> On 3/17/21 11:56 PM, enh via Toybox wrote:
> > Noticed while using telnetd to manually test some telnet fixes: telnetd
> > would sometimes exit when I'd disconnect because it couldn't find pid 0
> > on its list of sessions.
> >
> > I've not seen obscure exits because select() times out, but I've also
> > changed that `return` to an error_exit() so we'll at least know what's
> > happened if that ever occurs.
> >
> > Also use <arpa/telnet.h> rather than manually #define'ing its constants,
> > use the FLAG() macro throughout, and xsetsockopt(). Don't pointlessly
> > set errno to 0 at the start of main and then never look at it again.
>
> You've been poking at unexpected bits of pending recently. My post-sh todo
> has
> the "pending" files from Android.bp as prioritized for cleanup, ala:
>
>     "toys/pending/dd.c",
>     "toys/pending/diff.c",
>     "toys/pending/expr.c",
>     "toys/pending/getfattr.c",
>     "toys/pending/getopt.c",
>     "toys/pending/lsof.c",
>     "toys/pending/modprobe.c",
>

(modprobe isn't actually used on Android --- there's an Android modprobe
that reuses the same code that init uses. i just keep building this in case
anyone wants a second opinion :-) )


>     "toys/pending/more.c",
>     "toys/pending/readelf.c",
>

(let me know before you get to this one so i can try to flush my nm.c to
you first...)


>     "toys/pending/stty.c",
>     "toys/pending/traceroute.c",
>

(also not used on Android, but there for second opinions [and because we
don't ship iputils on the device, that's just for local testing, but we do
ship toybox].)


>     "toys/pending/tr.c",
>     "toys/pending/vi.c",
>
> Neither init nor telnet are on there. (Not complaining, happy for the
> help, but
> is there something I should know about?)
>

no, i just occasionally go scouting for random bugs from others.

https://www.google.com/search?q=perfcrastination

apparently there are people with devices they have to talk to using telnet,
and the special case of CR handling in existing toybox telnet.c wasn't
working for them. they hard-coded it the other way (which was all they
needed), and i stepped in the time machine back to the 1990s and re-read
the telnet RFCs. (because when you're as old and crufty as telnet, and were
heavily used from the 1970s to the 1990s, you're spread across far too many
RFCs!)

telnet.c was interesting because i fell into one of your traps (as you'll
see now i've finally sent the patch) accidentally rewriting most of the
file as i tried to understand it. even while writing the belated commit
message just now i thought of another slight cleanup, but i hit send anyway
and will worry about that later!


> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210422/7580cbde/attachment.html>


More information about the Toybox mailing list