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 25788 invoked from network); 20 Jun 2022 06:00:25 -0000 Received: from tb-ob21.topicbox.com (173.228.157.67) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2022 06:00:25 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob21.topicbox.com (Postfix) with ESMTP id 82BB8300CA for ; Mon, 20 Jun 2022 02:00:22 -0400 (EDT) (envelope-from bounce.mMeda7cacd5cce9cc74c1ddaf8.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 39DDC2925CAA; Mon, 20 Jun 2022 02:00:22 -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=1655704822; bh=x4OLk2LGg77ym2Dx SLOI9UT0Hm/FC8cUxFrxJiON4BE=; b=W8Uani2alIihZ4s2STqZys+vjdIcTDDW 5KbkYfvXUH63AE2ouVOnueovIzg29NJHokGjm6awnqe3dTUu6/MUb0bTS1PSOCOd 2lxW3HqdFHm7Q7gGtu/yt6Cgi+q4qfIhRjT/Xua4wvJoM1EDnr3EPfKpCx3V2mJx Ry+V8r3Fe+c= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1655704822; b=j69LOIu6wIqpC7CLt4hSuz0oStta1cbquyYQj9N2X6IvtLTrTX AE+CKhRNzV5N+GYyLwhDkXiCYQDo5K3pxAB9NmUwjrAYqrjAARlSOvh4J2sz7AUA 3gVtAtN1L5NdPMUAeIAqoTVUBfOD3O2okCvOPckZLO4h0DZhZCYGCj44c= 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=1655704822; x=1655791222; bh=GG75Y30NvjJ/ca7V7H467fW/5LA/oUp0 8t2Be15jvKo=; b=GP7dhyM7T3PkR2FA+y2bvT3ktKggO8B663P/UIoWpuI0TYZt DJBYcorqcGZ/hUFx/Crrax+c/AlkIm4Km7uLoigXK8+QlKlzUjeOT7i9RAzYrOsu xJyb1frtLaI2MyOjI46x3VMvIZ9JPg9d3AzgiQmht0E/d1ZmgrCkM4dbgLA= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id D88E1292585C for <9fans@9fans.net>; Mon, 20 Jun 2022 02:00:00 -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 AA7C20A9493; Mon, 20 Jun 2022 02:00:00 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1655704800; b=NpzQiEC21Antyo9UxckegknaXvB9GdVNGLUZvKZYjFJyQHUu8K /XePKGwgH/PftuezzE6pGHukKvHZG/+ym2wCaIJD+j7PTk1Lu6j0EAobxsK3cReT lQZ91Cm+CpC9jc4+95deZhCKG27t08q2J9BQD2K0gK4FV5UxnW79XzFDFfwAYriH JDnorAsb8zv7AmWgFPYUelZx73/CCdTGhuJzEzAserEgX1nc3lKFcb3w9G9CyDs2 Lo7H0PtZwENEJIBihcTKJA4E/BTPM1SG8c2PwsdO/e3liRb8Bcbb8zwsGp3n8ezl ebZ8iEnbKcT/0KsJ0PtABmtg11+5IK4f99hA== 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=1655704800; bh=JrvcspnVufKWQw5/oU2aYjmkAK/R073AEZPwx/Kzwyw=; b=VBf3OqluL4GY xJDxRemYSNVaVFOmJ9z27t+be/DPr/ZFGDMEcJTXWhGoEJVvY9H+3zw9aLZR57M+ BlhDTkdy6DjhE7zv0oEXwwiqIznTjKnu9SPvF9Gw4bHqiGbzi5lFdblBjpr2nm6M nawkJVCxsBBkF6Ndkmq1qU4ENPZM9chJexf1udQ3HkKSU1Kg2ANxFrmby4kD6ypl kYxCcpxet9sBT5wlD0sbFbtXeEOK2misMi/u0nhNVosUxDajRCyVYrd1WAc3I5xI VBb0CNnE6vo7jWTWng8EPMuFZ1P9vXU6kbpE2KdxrL7iF32OnivbQnrijxkvE2Ri guXTXD9cSw== 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: gggruggvucftvghtrhhoucdtuddrgedvfedrudeftddguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvf fujgfkfhggtgesthdtredttddtvdenucfhrhhomheprggurhcuoegrughrsefufffhrdfq tffiqeenucggtffrrghtthgvrhhnpeekhedtveffheevhfdtgefhhefgveelvedujeetje dtheduvdefvdekgedtfffhffenucfkphepvddthedrudeiiedrleegrddvgedpvddthedr udeiiedrleegrdduieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvg htpedvtdehrdduieeirdelgedrvdegpdhhvghlohepmhigrdhsughfrdhorhhgpdhmrghi lhhfrhhomhepoegrughrsefufffhrdfqtffiqe 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>; Mon, 20 Jun 2022 01:59:59 -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 25K5xwlu028495 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for <9fans@9fans.net>; Mon, 20 Jun 2022 05:59:58 GMT Received: from localhost (adr@localhost) by sdf.org (8.15.2/8.12.8/Submit) with ESMTP id 25K5xw8l004437 for <9fans@9fans.net>; Mon, 20 Jun 2022 05:59:58 GMT Date: Mon, 20 Jun 2022 05:59:58 +0000 (UTC) From: adr To: 9fans <9fans@9fans.net> Subject: Re: [9fans] syscall silently kill processes In-Reply-To: Message-ID: <2b857fe-c6df-a6b8-40ec-566c85b7377d@SDF.ORG> References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 3fc7d3c4-f05e-11ec-a894-e85351bf7eb6 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UZmE2ODIzMDQ4YWQ5MGEyMS1NZWRhN2NhY2Q1Y2NlOWNjNzRjMWRk?= =?UTF-8?B?YWY4Pg==?= 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:Meda7cacd5cce9cc74c1ddaf8:1:sc3EcReiwzFkxjQ0A02u-4QEGupr6WQW4GxSjdm8o2M On Mon, 20 Jun 2022, adr wrote: > But I have something in mind for a case like > this, when all the processes are going to use the same handler > (that's why I was asking). Let me play with it a litle before I > share it. Ok, the idea is this: If in is bigger than zero in threadnotify(int (*f)(void*, char*), int in), the handler is register for the calling process. If in is 0, then the handler is cleared for the calling process. If in is -1, the handler is register for all processes and if in is less than -1, it is cleared for all processes (expect for those who have already registered it for themselves). Now back to your example, as all the processes are going to use the same ha= ndler, you just have to register it once in threadmain: #include =20 #include =20 #include static int handler_alarm(void *, char *msg) { if(strstr(msg, "alarm")) return 1; return 0; } static void proc_udp(void *) { char resp[512]; char req[] =3D "request"; int fd; if((fd =3D dial("udp!185.157.221.201!5678", nil, nil, nil)) >=3D 0){ if(write(fd, req, strlen(req)) =3D=3D strlen(req)){ fprint(1, "start\n"); alarm(2000); read(fd, resp, sizeof(resp)); alarm(0); fprint(1, "end\n"); } close(fd); } threadexits(nil); } int mainstacksize =3D 5242880; void threadmain(int argc, char *argv[]) { threadnotify(handler_alarm, -1); for(int i =3D 0; i < 80; i++) proccreate(proc_udp, nil, 10240); sleep(5000); threadexitsall(nil); } Now, ; ./5.out | grep end | wc -l 80 Are you happy Andrej? adr. /sys/src/libthread/sched.c:=20 [...] if(t =3D=3D nil){ _threaddebug(DBGSCHED, "all threads gone; exiting"); cancelnotes(p->pid); _schedexit(p); }=20 [...]=20 /sys/src/libthread/note.c=20 [...]=20 int=20 threadnotify(int (*f)(void*, char*), int in)=20 { int i, frompid, topid; int (*from)(void*, char*), (*to)(void*, char*); if(in && in>-2){ from =3D nil; frompid =3D 0; to =3D f; topid =3D (in =3D=3D -1)? -1 : _threadgetproc()->pid; lock(&onnotelock); for(i=3D0; ipid; to =3D nil; topid =3D 0; } lock(&onnotelock); for(i=3D0; ipending) return; p->pending =3D 0; for(n=3Dnotes; nproc =3D=3D p){ for(i=3D0; ipid && onnotepid[i]!= =3D-1) || (fn =3D onnote[i])=3D=3Dnil) continue; if((*fn)(v, n->s)) break; [...] /sys/include/thread.h=20 [...]=20 void cancelnotes(int pid);=20 [...]=20 ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-Meda7c= acd5cce9cc74c1ddaf8 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription