From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 18b306de for ; Sat, 12 Jan 2019 02:34:19 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 9298494667; Sat, 12 Jan 2019 12:34:18 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id E30AE94666; Sat, 12 Jan 2019 12:33:25 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20150623.gappssmtp.com header.i=@bsdimp-com.20150623.gappssmtp.com header.b="CUsSKOR5"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 2E94494666; Sat, 12 Jan 2019 12:33:23 +1000 (AEST) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by minnie.tuhs.org (Postfix) with ESMTPS id 25F3C93D29 for ; Sat, 12 Jan 2019 12:33:22 +1000 (AEST) Received: by mail-qk1-f169.google.com with SMTP id 189so7694693qkj.8 for ; Fri, 11 Jan 2019 18:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MRUk4/PeoxwA/1KXfPDrbGPA7dIAUn8kojrida5kXW8=; b=CUsSKOR5s/kd5o4AqOQ+9OeUle5s76fSbRCfOqRU3XoXMNLlWoUxxlrsnjofNcTSIM o5qwRzYCOntAA0yw5mXwCM7kmc5CWWQvI7rk9GVG/qx8FmPaGKfzMQpq60FWxFgxMvn6 1+9hR8B1RGYckUoAWSngw2bv73PWQjONbSx9QhBJE3osF/P481v88/7S0hRXZBAQJgJu FzikgY4avfgdRRyQ8yQinPk3nMmKbMunhNXbPzvQlIaT9qjApBPE9zwC09hSx3cB7ehC hXwwcCe8fwT6mMrR2oPMcsE2md7qiHEnQdx/Toj9ypxEAgAieQFYOMlc2keWM+bO/y1b iixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MRUk4/PeoxwA/1KXfPDrbGPA7dIAUn8kojrida5kXW8=; b=N5WAIf1RaUy9skrC6iv5gAgtFSmN0Hyuqh8zjXlfUAUsfNlF2gYrIB2Z6ayWFN8HUb X5+uZhfMzGgb2RZ3hkyu35ohcbODlqcSttABzMqitUTS3m3nGi3pyt6teWIDwWFCH3Y1 tpYx5tKmy3QOn8iChZ42bIadzr7vHzrgDiVexpHBaIDaIiAu0AOGQBmqlQ65RgttOkoR JjDclcmtgKbWmLH0oXdUa4/kHnxTnGy7vgGATNNpmPLOv1CTh+Hu1GE3GElSGFBkaVZY U4Xnxy/eaKZyyG8R7vUkIA6UQ+wRpEe5TbEyWPxmZTdsRFBEZzI3dk6EaCwo9KZQpJof jrDw== X-Gm-Message-State: AJcUukfXP/9Q6UXHHhnjqaQJ1Xl7iFUz4pF0CdwQdHdI5ovheTOSJGCB T3ae0fJlblJ/hqb4+gMyVQtVXRQPQzW+vcL7MZY3Zw== X-Google-Smtp-Source: ALg8bN77yMh9L1vlPCrXtROkk3tr0qIV5giXLfQu5NCR3Vhm5TbTNWQrJDfIyNPnwGtdHfoNyEw30IrtZPtLRhvYSms= X-Received: by 2002:a37:c653:: with SMTP id b80mr15785871qkj.245.1547260401027; Fri, 11 Jan 2019 18:33:21 -0800 (PST) MIME-Version: 1.0 References: <20190112012439.7D56A18C073@mercury.lcs.mit.edu> In-Reply-To: From: Warner Losh Date: Fri, 11 Jan 2019 19:33:10 -0700 Message-ID: To: Dave Horsfall Content-Type: multipart/alternative; boundary="00000000000094231f057f39a2a4" Subject: Re: [TUHS] V6 networking & alarm syscall X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --00000000000094231f057f39a2a4 Content-Type: text/plain; charset="UTF-8" On Fri, Jan 11, 2019 at 6:59 PM Dave Horsfall wrote: > On Fri, 11 Jan 2019, Noel Chiappa wrote: > > [ ... ] > > > ioctl (0, FIONREAD, &nch); > > if (nch == 0) { > > tk_yield (); > > continue; > > } > > } > > if ((c = getchar()) == EOF) { > > > > so that ioctl() must look to see if there is any data waiting in the > > terminal input buffer (I'm too lazy to go see what FIONREAD does, right > > at the moment). > > As I dimly recall (because I'm too sick/lazy to look it up), it returns > the number of characters in the input queue (at that time) so that you > won't block (and time out, if you wrote it thus). > > It was quite useful, if you didn't like the horrible semantics of > select(), or, for that matter, SysV poll() (?) which was only slightly > better. > > Of course, FIONREAD wasn't always reliable, because by the time you got to > using it the keyboard (l)user could have deleted some characters etc, and > you *could* be left there hanging on a timeout (with signals, which for > some reason I hate with a passion, as I've posted here before, as they > are just too brutal). > This is why RAW mode was born, but then you're duplicating the kernel cooking code in your ap :( > No doubt someone here will tell me that Plan9 did it right :-) I really > must run it up some time, before I finally kark it (I'm in my late 60s). > No doubt... Warner --00000000000094231f057f39a2a4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Jan 11, 2019 at 6:59 PM Dave Horsfall <dave@horsfall.org> wrote:
On Fri, 11 Jan 2019, Noel Ch= iappa wrote:

[ ... ]

>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ioctl (0, FIONREAD, &nch);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 if (nch =3D=3D 0) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tk_yield ();
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 continue;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((c =3D getc= har()) =3D=3D EOF) {
>
> so that ioctl() must look to see if there is any data waiting in the <= br> > terminal input buffer (I'm too lazy to go see what FIONREAD does, = right
> at the moment).

As I dimly recall (because I'm too sick/lazy to look it up), it returns=
the number of characters in the input queue (at that time) so that you
won't block (and time out, if you wrote it thus).

It was quite useful, if you didn't like the horrible semantics of
select(), or, for that matter, SysV poll() (?) which was only slightly
better.

Of course, FIONREAD wasn't always reliable, because by the time you got= to
using it the keyboard (l)user could have deleted some characters etc, and <= br> you *could* be left there hanging on a timeout (with signals, which for some reason I hate with a passion, as I've posted here before, as they =
are just too brutal).

This is why RAW m= ode was born, but then you're duplicating the kernel cooking code in yo= ur ap :(
=C2=A0
No doubt someone here will tell me that Plan9 did it right :-)=C2=A0 I real= ly
must run it up some time, before I finally kark it (I'm in my late 60s)= .

No doubt...

= Warner=C2=A0
--00000000000094231f057f39a2a4--