unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: M <maximedevos@telenet.be>
Cc: "Jonas Hahnfeld via Developers list for Guile,
	the GNU extensibility library" <guile-devel@gnu.org>
Subject: Re: How to abort a read from a socket after some time?
Date: Mon, 22 Jan 2024 12:38:19 +0100	[thread overview]
Message-ID: <Za5Tq2Q7BGn_5O2-@ws> (raw)
In-Reply-To: <20240122004625.dbmQ2B0062FFpwy01bmQ2u@baptiste.telenet-ops.be>

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]

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 Guile. Hence, the C signal handler is run (which sets some fields somewhere indicating 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 interrupted twice in a row, time such that the exception handler itself is interrupted with a new exception), Guile decides to retry the syscall

I am confused about this.  I read the documentation for sigaction, and there 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
          ‘EINTR’ 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 then?

Thank you,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2024-01-22 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Za0_ly1K7l3RV1hJ@ws>
2024-01-21 23:46 ` How to abort a read from a socket after some time? M
2024-01-22 11:38   ` Tomas Volf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Za5Tq2Q7BGn_5O2-@ws \
    --to=~@wolfsden.cz \
    --cc=guile-devel@gnu.org \
    --cc=maximedevos@telenet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).