From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr0-f178.google.com ([209.85.128.178]) by ur; Mon Mar 27 22:27:06 EDT 2017 Received: by mail-wr0-f178.google.com with SMTP id l43so82586226wre.1 for <9front@9front.org>; Mon, 27 Mar 2017 19:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=2MAHjUjmucxmv05OHA9zXaD283bBGGJjdzdvYRjwxMk=; b=UdOLZpCC2y2d8m/e2xUk+9ygLC39Y6e/XlMgpC4aiS49QcuUvQ0OxLGny1zgIkLv1D Mpcy0hlvOSQrHWt8bLu/0Vc+Wl5SEgJDJK37xJzOSb5zIyvKQLDB+3BdsI3qVHq+HcEb qOYK6O4pyOTAa9+qWuoBaVGOHvvY94IN1+iYOpYBBCN/GkMv4ngBxnJ7t4npNmmulQy8 ljIZk8tXulGpXcNclXRmEG9vtrE9l3Eznp3UwDoAqkBTMT2k9zTi4FgM9BT0TrxSYs+B 4npDEH8utiDTm+pdVOWv5zRb9KfuO5TIj+E+o9CrL0RIRxd4zxGVcJnn7uGOu2Rurmtm WcgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=2MAHjUjmucxmv05OHA9zXaD283bBGGJjdzdvYRjwxMk=; b=Vwyi3woZoPFv/l2KGRSIllNnsL91exeInACrsE/QJ+Zg7UWVA96aP+iYAzV0pUqUFZ PQFX/wkaVksZZctJSPsWEXLmLdEmMC3JoowaO9pgh2V/chdrOc1406wi0dTOJOmIguDl BugRjn0dKhYR11qsp4BqJmBxJ14cf5rUGBZp4syJNnSCh6DlPjZO1mVCjiyoVIIc/Irb VC0PB4wGn6mtiC76l/kHUL7LLXLPadwtoPG2fH8DpCwysDlWqGmf2XAPhM/2LLmm5ddM SWimm2/vcNA2zk5nXIDokQf/HadoMchi+i2n7MQxUDfKM2JZK8VfeEXEAfX1rB3EdLGg BoqA== X-Gm-Message-State: AFeK/H2zQ8uASCLU7mBgD7jezBm1/4auyMi3zbFgBqZhFQn2u/+NHbgwDCgP1r9SfacJWX7tqTpxmlJxkxkNrQ== X-Received: by 10.28.157.140 with SMTP id g134mr12587680wme.81.1490668023992; Mon, 27 Mar 2017 19:27:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.178.132 with HTTP; Mon, 27 Mar 2017 19:27:03 -0700 (PDT) In-Reply-To: References: From: Alex Musolino Date: Tue, 28 Mar 2017 12:57:03 +1030 Message-ID: Subject: Re: [9front] pipe: bug or feature? To: 9front@9front.org Content-Type: multipart/alternative; boundary=001a114b41e40c5718054bc132e1 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: scale-out managed DOM database framework --001a114b41e40c5718054bc132e1 Content-Type: text/plain; charset=UTF-8 > > is this a bug or a feature of pipe? > It is a bug in your code. When you do buf[n] = 0 in the last while loop, you are writing past the end of buf. This causes pfd[0] to become 0 and so the next read is actually from stdin. Making buf larger "fixes" the problem because n=256 becomes a valid index. -- Cheers, Alex Musolino --001a114b41e40c5718054bc132e1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
is this a bug or a feature of= pipe?

It is a bug in your code.= =C2=A0 When you do buf[n] =3D 0 in the last while
loop, you are w= riting past the end of buf.=C2=A0 This causes pfd[0] to
become 0 = and so the next read is actually from stdin.=C2=A0 Making buf
lar= ger "fixes" the problem because n=3D256 becomes a valid index.

--
Cheers,<= br>Alex Musolino
--001a114b41e40c5718054bc132e1--