From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Volf <~@wolfsden.cz> Newsgroups: gmane.lisp.guile.devel Subject: Re: How to abort a read from a socket after some time? Date: Mon, 22 Jan 2024 12:38:19 +0100 Message-ID: References: <20240122004625.dbmQ2B0062FFpwy01bmQ2u@baptiste.telenet-ops.be> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AUeJDXfjqN6Vcoev" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13939"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "Jonas Hahnfeld via Developers list for Guile, the GNU extensibility library" To: M Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Mon Jan 22 12:38:56 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rRsdj-0003Nm-RN for guile-devel@m.gmane-mx.org; Mon, 22 Jan 2024 12:38:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rRsdH-0001Rl-HT; Mon, 22 Jan 2024 06:38:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1rRsdG-0001R4-1l for guile-devel@gnu.org; Mon, 22 Jan 2024 06:38:26 -0500 Original-Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1rRsdD-00037k-OD for guile-devel@gnu.org; Mon, 22 Jan 2024 06:38:25 -0500 Original-Received: by wolfsden.cz (Postfix, from userid 104) id 5B1F7274248; Mon, 22 Jan 2024 11:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1705923500; bh=9Pqv83pydFEbrrCBaJJk2Y4JjR8O3gBYamEo3G8YCeU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=NbbbFmRIztteOW8LWBMkx6pq2BUPEDLA/LP8ksQmuLRwKjiAV8EGUKAE2ZIhufzbh ZldkGgr5Rmo3FoYiVxkpeNrClChh3R7xu4TBzRSZTgSYjFoCC6ZdTRnzia6DfwR2AV NkFVKBkn3eF8VaGRuEQVL9BjnMSkzx8Wj11Bn7uGB/UXLRsAA0+7clwDqrR5bT9ukV bfJTwi6FJL0vP3I1wi7yW0EoLWdhymRyZ2BS6rJ8O2zR32fTeRghyb1fL4k75I7gle x7Morn9ZUptEjSEQ9Q6i2XwVZtsDBbhZXzG7XITd3LjjYEvXBKqaf1LdYrX17doLZX jimv+vfMbAsCC0QZEpx61yTzIZggq7hPYnRGHefNmPkwUf51wDU8NZH5UgVE4p6jWC ejvWEA5jUrhgF2i2sunV9R81Zn+cLrwquH8sW6hIQjMaWfNuajrxPEfHDT4m/MuoY6 kTKxd4cGz8/XXXTW0TVFU2OXc52naf7ILjx/pT6kv7FzZ8w9nVV2eVvju+Ouv5T7Ks Iqj10Mm8tKB2qu3Rvl6V+lE/ll19D7HarNXYEZ3EQPuqnqLCWP/N78oo8wrRdoypZH O6yeAZwRATf2yWU2UXtuPwVh03q/cSlmIf6w9ST6gW0rY8DGORz6bKwk4kSkTCW95j hnpIuscrOR9YLCweHDviOmvw= Original-Received: from localhost (unknown [146.70.134.132]) by wolfsden.cz (Postfix) with ESMTPSA id E12332735E5; Mon, 22 Jan 2024 11:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1705923500; bh=9Pqv83pydFEbrrCBaJJk2Y4JjR8O3gBYamEo3G8YCeU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=NbbbFmRIztteOW8LWBMkx6pq2BUPEDLA/LP8ksQmuLRwKjiAV8EGUKAE2ZIhufzbh ZldkGgr5Rmo3FoYiVxkpeNrClChh3R7xu4TBzRSZTgSYjFoCC6ZdTRnzia6DfwR2AV NkFVKBkn3eF8VaGRuEQVL9BjnMSkzx8Wj11Bn7uGB/UXLRsAA0+7clwDqrR5bT9ukV bfJTwi6FJL0vP3I1wi7yW0EoLWdhymRyZ2BS6rJ8O2zR32fTeRghyb1fL4k75I7gle x7Morn9ZUptEjSEQ9Q6i2XwVZtsDBbhZXzG7XITd3LjjYEvXBKqaf1LdYrX17doLZX jimv+vfMbAsCC0QZEpx61yTzIZggq7hPYnRGHefNmPkwUf51wDU8NZH5UgVE4p6jWC ejvWEA5jUrhgF2i2sunV9R81Zn+cLrwquH8sW6hIQjMaWfNuajrxPEfHDT4m/MuoY6 kTKxd4cGz8/XXXTW0TVFU2OXc52naf7ILjx/pT6kv7FzZ8w9nVV2eVvju+Ouv5T7Ks Iqj10Mm8tKB2qu3Rvl6V+lE/ll19D7HarNXYEZ3EQPuqnqLCWP/N78oo8wrRdoypZH O6yeAZwRATf2yWU2UXtuPwVh03q/cSlmIf6w9ST6gW0rY8DGORz6bKwk4kSkTCW95j hnpIuscrOR9YLCweHDviOmvw= Content-Disposition: inline In-Reply-To: <20240122004625.dbmQ2B0062FFpwy01bmQ2u@baptiste.telenet-ops.be> Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22280 Archived-At: --AUeJDXfjqN6Vcoev Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, thank you very much for the email and the suggested approach, I will try it= out. I just have one more question: On 2024-01-22 00:46:23 +0100, M wrote: > > > > All code below runs after handler is set: > > > > (sigaction SIGALRM (lambda _ (display "Alarm!\n"))) > > Assuming the read-char takes too long, the kernel sends a SIGALRM to Guil= e. Hence, the C signal handler is run (which sets some fields somewhere ind= icating that this handler should be run later in the sense of system-async-= mark), and the syscall behind read-char returns EINTR. > > As this is a fake error (passing it on as a Scheme exception would result= in rather messy semantics, e.g. consider the case where things are interru= pted twice in a row, time such that the exception handler itself is interru= pted with a new exception), Guile decides to retry the syscall I am confused about this. I read the documentation for sigaction, and ther= e is this text for the flags argument: -- Variable: SA_RESTART If a signal occurs while in a system call, deliver the signal then restart the system call (as opposed to returning an =E2=80=98EINTR=E2=80=99 error from that call). Based on that my expectation was to get EINTR. But since the syscall seems= to be restarted even without the SA_RESTART, what exactly does this flag do th= en? Thank you, Tomas Volf -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --AUeJDXfjqN6Vcoev Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmWuU6sACgkQL7/ufbZ/ walltQ//Qpg2YXSqmpwfEqz3vivOxbnnl3xUqxIzM86I1ozR0q/NwKg7ul+0CV07 haKdsosrwnz/te1gug4UGkC3aZ7rNcb9AJySIAeRyQtKDVaaLH5P+QAHT6ROwtXB QMfsI8Dns0pXkdrWPq4vBZS93Dxva7HhfbedluSULffQXPWWrp26t8tzsHhpGh+F bZYloAvWHqlnjOEa4/tkZ7vlQGtf4yAilHp3fGi3U3Ug1L3/lV4Fuz2pTSkWUoPS hc9Z1S3kc3opp/gQUVkz18+XBqsC5pIVxIgfWRA1CwllHE+AcTTEmDjE0/yHCwm8 M+ay/MKu/myc7zl0ABfUK1bab//r9/NEvlIvntHIsET5FJimh8T0cHvTCVV02yku yo8VNu01VUqgVRYTWhKAcRr8r1hc+LfL/gyAfN2QcUb0/vuGFCeP91kMzuQQXgo0 ahXOGXzqytLASYBp7a28Zw6ZCfP9EnP4KvpYjma5oqg+mmXQVCvCq03seyyeb9dy eZpA3sPGhuLOC+5xPqghF3v3/d+H1++yAUWuFoXMqsMicfzs3tSsfR9PPYDpDCst AzflQ+QrNiACjCofYQO6ZjF54o0I62lwVq23ApYzKCImZVHWExa7UGfBRounmprt r51jFVp0eXYKR2drcRH4apvq2WOtLVd/tMqxSqqo6JR7PSLQg8E= =r7SI -----END PGP SIGNATURE----- --AUeJDXfjqN6Vcoev--