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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11096 invoked from network); 8 Jul 2023 15:47:00 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 8 Jul 2023 15:47:00 -0000 Received: from tb-mx1.topicbox.com (tb-mx1.nyi.icgroup.com [10.90.30.61]) by tb-ob0.topicbox.com (Postfix) with ESMTP id 6F35424257 for ; Sat, 8 Jul 2023 11:46:58 -0400 (EDT) (envelope-from bounce.mMa261d9fb098775daa526c6b3.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx1.topicbox.com (Postfix, from userid 1132) id 6C8B91E5E637; Sat, 8 Jul 2023 11:46:58 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=protonmail.com header.i=@protonmail.com header.b=c4ISoGRa header.a=rsa-sha256 header.s=protonmail3 x-bits=2048; dmarc=pass policy.published-domain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=protonmail.com; spf=pass smtp.mailfrom=philip.silva@protonmail.com smtp.helo=mail-40134.protonmail.ch; 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:to:message-id:mime-version:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:subject:from:list-unsubscribe; s= sysmsg-1; t=1688831218; bh=9TkDRWim9hmd8CWrrG0zae32V7wkkam69iV4/ UcYYNw=; b=e/8ke7pLJsvzr4uB+Ctp1f4NTL4flZdZq6AdDKlrlPjSi0XG7w7aF 9PZVsd8SNBq4Ne2Dp5AHWCz7qsemc1LN4aenmm+bxC6lpBAEJKFoVa6RFg11ZWRM nIXyg3lsccBswBng8ifzzlcqHdWKoaqo+QSaCQXOg8pNLpA2cIz6So= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1688831218; b=aZbkpdzo4jPgODKLjF+Q1HhCebKgy4H80p7yWfeVEq1aLJt3a2 4BWMwtVLhu4B5u/E4NYtnYoKiCefBgl8VD/bZbmFL45mkSJABuRHMO7/UE8eJ3Rg pGdnfirpWFPwKtMSSIHpmyqSh4h2+5vq7b9QtA1INGxRP2uj1iwlRThlI= Authentication-Results: topicbox.com; arc=pass; dkim=pass (2048-bit rsa key sha256) header.d=protonmail.com header.i=@protonmail.com header.b=c4ISoGRa header.a=rsa-sha256 header.s=protonmail3 x-bits=2048; dmarc=pass policy.published-domain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=protonmail.com; spf=pass smtp.mailfrom=philip.silva@protonmail.com smtp.helo=mail-40134.protonmail.ch; 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=declined (Domain declined to participate); dkim=pass (2048-bit rsa key sha256) header.d=protonmail.com header.i=@protonmail.com header.b=c4ISoGRa header.a=rsa-sha256 header.s=protonmail3 x-bits=2048; dmarc=pass policy.published-domain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=protonmail.com; iprev=pass smtp.remote-ip=185.70.40.134 (mail-40134.protonmail.ch); spf=pass smtp.mailfrom=philip.silva@protonmail.com smtp.helo=mail-40134.protonmail.ch; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mail-40134.protonmail.ch policy.ptr=mail-40134.protonmail.ch; x-return-mx=pass header.domain=protonmail.com policy.is_org=yes (MX Records found: mailsec.protonmail.ch,mail.protonmail.ch); x-return-mx=pass smtp.domain=protonmail.com policy.is_org=yes (MX Records found: mailsec.protonmail.ch,mail.protonmail.ch); 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:to :message-id:mime-version:content-type:content-transfer-encoding :list-help:list-id:list-post:list-subscribe:reply-to:subject :from:list-unsubscribe; s=dkim-1; t=1688831218; x=1688917618; bh=3GlVj+mxVzMk1KSnWNj7yjU/HKjmSh3ADkgtGFn9ng8=; b=Ux5YalMAlIRt j2FxMeRYVdSmswLqxO1wYJ8sfImcmcFYdirAo2NG7saDnmRVAmupzWG7waIkOdQz qVHdI3kAcXSMaR1xUns0qrNi0fP1R6dO/ouRwKXT/NY8heaIn7H81XO5yfnEk67f yo3HEbb9IrMx4X+muBoli2WGNlbAz80= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id 6D0EE1FACB9D for <9fans@9fans.net>; Sat, 8 Jul 2023 11:46:45 -0400 (EDT) (envelope-from philip.silva@protonmail.com) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id BF22BEEC3F4; Sat, 8 Jul 2023 11:46:45 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1688831205; b=egNFfR8f2e+B3hxFIe4re6pXTFup1au9p8qXxZsGJMfZ3+bpGc bmpJpqCoiia0DDZn+o1zN//cYp6H7qBl0CMgm4KCmwbjy4RGCz4vh7FHxXxKf+gD XfoTjmV+aG+sX3ndKC2fu+w7jtvnwErhLQyaz4TCsAN24gmXww9DEmmTd/rZOGQI gbKQ3jAwaO/bGeFyr62w6TnMd8nQPG76bFAI6dAnUMz02xHwAaSC3HHQ5vBGzWlm zcRpgBE27l8CJWh5MdSdmQVgeBGYEq6D0nESQahWENyafdoMO+zGiBmLvzag3Cks i2r3w8XNK6UztQB9JK5wLfbr41/XqvsZfckQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:to:from:subject:message-id:mime-version :content-type:content-transfer-encoding; s=arcseal; t= 1688831205; bh=hU0MaZ34r5RR5y/taR8XVqi+774O/oxJAxBnPdr0JkY=; b=R SIlITOmx9Y6t6hxmt9o24V83UlkmK+jHj2dAlcEEeeDGlOYaCPwgcIIkHAWQ5X7s PrpXHcrtPuu8TQdNlTSpFA7LnIkXOUdqgRHYqcMb+yOF72rQDmTKSJEH6TwgmEE5 QZH0GiZgzPAvaGdiIBmF04XdC3Hm5cvQ4qorOBKN7exZpgeJW6AMRLrbg01wLH4n OeM0nE0Vj5Is3JWc7iwxFmPsXH9JmlGdGTBPtM/SyWBw9eBO9Lw4sq08dZfwlClv n/OSWChGJvBXXGBfdLHgjj+VJ3u91LcU3uaMcooPZCYuEGKzjKu4rqIcetIghFQS RAqTsU1u0/lHTrYNU4caQ== ARC-Authentication-Results: i=1; tb-mx0.topicbox.com; arc=none (no signatures found); bimi=declined (Domain declined to participate); dkim=pass (2048-bit rsa key sha256) header.d=protonmail.com header.i=@protonmail.com header.b=c4ISoGRa header.a=rsa-sha256 header.s=protonmail3 x-bits=2048; dmarc=pass policy.published-domain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=protonmail.com; iprev=pass smtp.remote-ip=185.70.40.134 (mail-40134.protonmail.ch); spf=pass smtp.mailfrom=philip.silva@protonmail.com smtp.helo=mail-40134.protonmail.ch; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mail-40134.protonmail.ch policy.ptr=mail-40134.protonmail.ch; x-return-mx=pass header.domain=protonmail.com policy.is_org=yes (MX Records found: mailsec.protonmail.ch,mail.protonmail.ch); x-return-mx=pass smtp.domain=protonmail.com policy.is_org=yes (MX Records found: mailsec.protonmail.ch,mail.protonmail.ch); 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: gggruggvucftvghtrhhoucdtuddrgedviedrvdefgdelgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffvhffukf ggtgfgsehtqhertddttdejnecuhfhrohhmpefrhhhilhhiphcuufhilhhvrgcuoehphhhi lhhiphdrshhilhhvrgesphhrohhtohhnmhgrihhlrdgtohhmqeenucggtffrrghtthgvrh hnpeehhffffeeujeevudehieektdfhieettddthfeihfejvdethfdulefhjeetiefhueen ucfkphepudekhedrjedtrdegtddrudefgeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepihhnvghtpedukeehrdejtddrgedtrddufeegpdhhvghlohepmhgrihhlqdeg tddufeegrdhprhhothhonhhmrghilhdrtghhpdhmrghilhhfrhhomhepoehphhhilhhiph drshhilhhvrgesphhrohhtohhnmhgrihhlrdgtohhmqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (protonmail.com: Sender is authorized to use 'philip.silva@protonmail.com' in 'mfrom' identity (mechanism 'include:_spf.protonmail.ch' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="philip.silva@protonmail.com"; helo=mail-40134.protonmail.ch; client-ip=185.70.40.134 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) (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>; Sat, 8 Jul 2023 11:46:44 -0400 (EDT) (envelope-from philip.silva@protonmail.com) Date: Sat, 08 Jul 2023 15:46:23 +0000 To: 9fans <9fans@9fans.net> Message-ID: Feedback-ID: 4491819:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: a72770a8-1da6-11ee-8373-9ac8fc8b7b06 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UMzM5MjAwMWEwMmVlN2VjOC1NYTI2MWQ5ZmIwOTg3NzVkYWE1MjZj?= =?UTF-8?B?NmIzPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Subject: [9fans] Pipes staying after sending note From: "Philip Silva via 9fans" <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Ma261d9fb098775daa526c6b3:1:rJmGk7qEVLJkHLxPm4_V3FGmlGAxZNzFTf703n9zjEQ Hello, I'm trying to understand how pipes work when terminating a forked process. = It seems when sending kill to the forked process, connected pipes don't alw= ays break. At least a subsequent write might work. Is it possible to make i= t reliably fail anyway or is it necessary to close the file descriptors fro= m the calling process? #include #include #include void sendnote(int cpid) { int fd; char fn[20], buf[20]; sprintf(fn, "/proc/%d/note", cpid); if ((fd =3D open(fn, OWRITE)) <=3D 0) { printf("open %s\n", fd); } if (write(fd, "kill", 5) =3D=3D 0) { printf("write error\n"); } close(fd); return; } int main() { int cpid, infd[2], outfd[2], n; char outbuf[20], inbuf[20]; char *args[] =3D {"/bin/cat", NULL}; pipe(infd); pipe(outfd); if ((cpid =3D fork()) !=3D 0) { close(infd[1]); close(outfd[1]); n =3D write(infd[0], "test", 4); printf("check process: wrote %d bytes\n", n); sendnote(cpid); // close(infd[0]); // <--- uncomment to make write fail // close(outfd[0]); n =3D write(infd[0], "test2", 5); printf("write: wrote %d bytes\n", n); n =3D read(outfd[0], outbuf, 20); printf("outbuf=3D%s (n=3D%d)\n", outbuf, n); wait(); return 0; } dup(infd[1], 0); close(infd[0]); close(infd[1]); dup(outfd[1], 1); close(outfd[0]); close(outfd[1]); exec("/bin/cat", args); return 0; } Will output: check process: wrote 4 bytes write: wrote 5 bytes outbuf=3Dtest (n=3D4) 6.out 82435: main Closing the FDs after sending the note: check process: wrote 4 bytes write: wrote -1 bytes outbuf=3D (n=3D-1) 6.out 82423: main On the other hand instead of closing just adding sleep(1) after sendnote() = produces: check process: wrote 4 bytes 6.out 82595: sys: write on closed pipe pc=3D0x202603 (That's more or less also reproducing a part of Go's os/exec TestContextCan= cel) Greetings, Philip ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T3392001a02ee7ec8-Ma261d= 9fb098775daa526c6b3 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription