From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8767 invoked from network); 19 Jun 2022 05:55:14 -0000 Received: from tb-ob1.topicbox.com (64.147.108.173) by inbox.vuxu.org with ESMTPUTF8; 19 Jun 2022 05:55:14 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob1.topicbox.com (Postfix) with ESMTP id 3BF9B2056A for ; Sun, 19 Jun 2022 01:55:09 -0400 (EDT) (envelope-from bounce.mM6e48031f9e8673387c0b47b8.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 40DA9290BCA9; Sun, 19 Jun 2022 01:55:09 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type:list-help:list-id :list-post:list-subscribe:reply-to:content-transfer-encoding :list-unsubscribe; s=sysmsg-1; t=1655618109; bh=MOtP/02IVmjujStF T0QIhR85JTse4b9iFTK53pmKOqc=; b=OgJYf4yFgmEzRdvIV21opQRB69SHkIDC UNQU5JATBwQ2NbiLYqFnXD69RhJmUWgqFRIQZKIUbWpF1FN5ywwc4jdOCEWlI/Iz 4/hDAyMH416wF5ItDGNPUz6mwdpwP5Q4ZrviMIjen3RmKEKJIJwjPZnRZAmiycqF EHen6zZW6o0= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1655618109; b=g++pypq4LFcxyhk8lQ5b28SJG/JBUyiR/7CcUK5nkjgnDRMKO7 Nc7D6XNJT9cVTjOqCapWIaeBrBt+vbSbGsRvQlR5FCqNuoEV2SbdSh0RTDmyu3eh uQhzoux42VRQOpCBuDH7Ej4Mo41H49BLBm2bUDsqyenCYpOcgKkgWgJ6c= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=date:from :to:subject:in-reply-to:message-id:references:mime-version :content-type:list-help:list-id:list-post:list-subscribe :reply-to:content-transfer-encoding:list-unsubscribe; s=dkim-1; t=1655618109; x=1655704509; bh=BVum8EfWfysnf4WTUPL0NLk7bq5Rp+s7 VopMgxIaEy0=; b=S4Jl1gd4qHVorrykSuw2Mg3vm5hHg4OKM5bFJI2huqdiMvMt vT5flF9dGs3jsqb22pUwEenIK7oAwx2cH23vLPeAjTOrdeqrZ6oPEADjjMhC4UQY Ae6fc1wRWjl4VAbHfnLWAxOFe2pXuX+wgWYPtqHPKzof0JDE4e/+/IMhHNE= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id 5ED83290B884 for <9fans@9fans.net>; Sun, 19 Jun 2022 01:54:54 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id 4D3A0CC2FC5; Sun, 19 Jun 2022 01:54:54 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1655618094; b=FfVIoiftkkbUDSXnBoGDPCCZeWCo9yUTQkD1+M1OkA+ZU3PaUj pce5a9N55BJ5MXb6u8JtmXnIOOiV/eylk+UEZVXeZdf/4kNxYSxayQC/6e2i+g5C h7Emg4fFtEIEb4IK+kAiHfDOMcMNt01i8ikijilV4ZJcm2SCZSVG10Gf9xyOyyma 4aU1sdW78ujET2WO6dsSf3t/u50S+HvpqRzcKijbfvza1fNVt1lMuZ4l1sO1Hmxe /JNA1xUnk6B+oVbWEriamCuCtliojVi93FvHcv/s+auCvhPaEkhA4vCaO9jgeUHi d+ec0quSjOdUN9pMWKbPHkoR2MwuWzwAr2nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type; s=arcseal; t=1655618094; bh=do8+Db1IbE4pptt/wgKhZVVTq7lZB8Hk6gQLzV2GDzg=; b=GZuUM+3qtA3d ohShj5MIMLNP+1T/fdS18aN/mL9uuqpkeXc9e0zH6vSLxKz0AVgAFcp4dUpV5bnc M5rAxSgn6Rp9HfuZriXsSI3mU4PjzhH39GZgCJyKDh9sA7acmQefvUKDUb970Y18 9NaL84cNPlnfPQTP1kWUA1VHP4rLa8A9LOBzI+5EpxYSAvxoxER4MzmkuOshHUF2 b2TXMt19mTLvpae7sfF1brxJtQbz7lFnTTNqMEJLUKcvGKXUPZHo+HwgjdD0Isrh a3hzfkoplt9eRBVTxb3WSi7+Z4O80BfRhJpJOHTm8JC4HIC2/0883TA4KmmL1422 a4TLt40V4g== ARC-Authentication-Results: i=1; tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvkedgleekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf gjkfhfgggtsehttdertddttddvnecuhfhrohhmpegrughruceorggurhesufffhfdrqfft ifeqnecuggftrfgrthhtvghrnhepieefueegveetfeeihfefgeejiefhvedtiefghffhle eiheetgefhveeiheejtddunecuffhomhgrihhnpehmrghrtgdrihhnfhhonecukfhppedv tdehrdduieeirdelgedrvdegpddvtdehrdduieeirdelgedrudeinecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehinhgvthepvddthedrudeiiedrleegrddvgedphhgv lhhopehmgidrshgufhdrohhrghdpmhgrihhlfhhrohhmpeeorggurhesufffhfdrqfftif eq X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (sdf.org: 205.166.94.24 is authorized to use 'adr@SDF.ORG' in 'mfrom' identity (mechanism 'ip4:205.166.94.0/24' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="adr@SDF.ORG"; helo=mx.sdf.org; client-ip=205.166.94.24 Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx0.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Sun, 19 Jun 2022 01:54:53 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from sdf.org (IDENT:adr@sdf.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 25J5sqfB017504 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for <9fans@9fans.net>; Sun, 19 Jun 2022 05:54:52 GMT Received: from localhost (adr@localhost) by sdf.org (8.15.2/8.12.8/Submit) with ESMTP id 25J5sqEE025230 for <9fans@9fans.net>; Sun, 19 Jun 2022 05:54:52 GMT Date: Sun, 19 Jun 2022 05:54:52 +0000 (UTC) From: adr To: 9fans <9fans@9fans.net> Subject: Re: [9fans] syscall silently kill processes In-Reply-To: <55d376e1-fddb-135c-c7e3-ffca9ed621d7@posixcafe.org> Message-ID: References: <79286caa2ca77ea9b9a1cd64918bdc5f28c8f180.camel@gmail.com> <9e922645a598c69ba14b74e18e8669cc068e9717.camel@gmail.com> <0e5677e6-684d-ff37-c6cd-430d18536070@posixcafe.org> <3889a52-3fe4-c28-1c3b-a73412a489@SDF.ORG> <64a85bad-7ab-fb6-6517-acfafa819bc@SDF.ORG> <5e2f8566-da80-6c40-9718-3a9199434e7d@SDF.ORG> <55d376e1-fddb-135c-c7e3-ffca9ed621d7@posixcafe.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 5a50c8a6-ef94-11ec-a44f-e9d862f47282 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UZmE2ODIzMDQ4YWQ5MGEyMS1NNmU0ODAzMWY5ZTg2NzMzODdjMGI0?= =?UTF-8?B?N2I4Pg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Content-Transfer-Encoding: quoted-printable List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M6e48031f9e8673387c0b47b8:1:-VyPudMGIgx8E0a3phST-k3mJI2CxG40B23gqEEG6n4 On Sat, 18 Jun 2022, Jacob Moody wrote: > I've attempted to reproduce it, trying to remove the libthread/notify > factors. I've come up with this: > > #include > #include > > static void > proc_udp(void*) > { > char resp[512]; > char req[] =3D "request"; > int fd; > int n; > int pid; > > fd =3D dial("udp!185.157.221.201!5678", nil, nil, nil); > if(fd < 0) > exits("can't dial"); > > if(write(fd, req, strlen(req)) !=3D strlen(req)) > exits("can't write"); > > pid =3D getpid(); > fprint(1, "start %d\n", pid); > n =3D read(fd, resp, sizeof(resp)-1); > fprint(1, "end %d %d\n", pid, n); > exits(nil); > } > > void > main(int, char**) > { > int i; > Waitmsg *wm; > > for(i =3D 0; i < 10; i++){ > switch(fork()){ > case -1: > sysfatal("fork %r"); > case 0: > proc_udp(nil); > sysfatal("ret"); > default: > break; > } > } > for(i =3D 0; i < 10; i++){ > wm =3D wait(); > print("proc %d died with message %s\n", wm->pid, wm->msg); > } > exits(nil); > } > > This code makes it pretty obvious that we are losing some children; > on my machine this program never exits. I see some portion of the > readers correctly returning -1, and the parent is able to get their > Waitmsg but not all of them. Moody I think this old thread will interest you: https://marc.info/?t=3D112730920400001&r=3D1&w=3D2 Russ Cox explained there: It appears that your program, at its core, it is doing this: void readproc(void *v) { int fd; char buf[100]; fd =3D (int)v; read(fd, buf, sizeof buf); } void threadmain(int argc, char **argv) { int p[2]; pipe(p); proccreate(readproc, (void*)p[0], 8192); proccreate(readproc, (void*)p[1], 8192); close(p[0]); /* and here you expect the first readproc to be done */ close(p[1]); /* and here the second */ } Each read call is holding up a reference to its channel inside the kernel, so that even though you've closed the fd and removed the ref from the fd table, there is still a reference to each side of the pipe in the form of the process blocked on the read. I've never been sure whether the implicit ref held during the system call is good behavior, but it's hard to change. In your case, writing 0 (or anything) makes the read finish, releasing the last ref to the underlying pipe when the system call finishes, and then everything cleans up as expected. So you've found your workaround, and now we understand why it works. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-M6e480= 31f9e8673387c0b47b8 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription