Groups | Search | Server Info | Login | Register


Groups > comp.lang.misc > #11295

Re: Interrupted system call on read after ~20 minutes inactivity?

From Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups comp.lang.misc, comp.lang.c
Subject Re: Interrupted system call on read after ~20 minutes inactivity?
Date 2025-10-04 00:28 +0000
Organization A noiseless patient Spider
Message-ID <20251003165522.137@kylheku.com> (permalink)
References <10bpkh1$25arg$1@dont-email.me> <a1ZDQ.88557$7Ika.30828@fx17.iad>

Cross-posted to 2 groups.

Show all headers | View raw


On 2025-10-03, Scott Lurndal <scott@slp53.sl.home> wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>>The maintainer of the Genie system told me that he has no such
>>logic implemented in his tool, and he suspected the libc as the
>>source of the interrupted system call.

Janis, Do you have some shell hack running with a background process that
delivers an alarm signal, and is that going to the entire process group?

> run the application under strace to see the system call that was
> interrupted.
>
>  $ strace -f -o syscall.tr genie -x 'read (newline)'

Bingo; the system call and any signal handling details.

Maybe the Genie run-time (is that accurate?) has some periodic signal to
do something.  Maybe that signal is being handled many times while
it is sitting in that TTY read, and the signal handling is being careful
to specify that a system call interrupted by the signal should be
restarted. And maybe there is some race condition in that where it
hiccups, resulting in an EINTR exposure.

I dojn't see such a thing in the latest Genie tarball, but in the
genie function in genie.c, this is called:

  void install_signal_handlers (void)
  {
    ABEND (signal (SIGINT, sigint_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
    ABEND (signal (SIGSEGV, sigsegv_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
    #if defined (SIGWINCH)
      ABEND (signal (SIGWINCH, sigwinch_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
    #endif
    #if defined (BUILD_UNIX)
      ABEND (signal (SIGALRM, sigalrm_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
      ABEND (signal (SIGPIPE, sigpipe_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
      ABEND (signal (SIGTTIN, sigttin_handler) == SIG_ERR, ERROR_ACTION, NO_TEXT);
    #endif
  }

It's using the ISO C signal function, which from the Posix point of
view is obsolescent; sigaction should be used.

On Linux, I think signal() has the BSD semantics for restarting;
for every signal, SA_RESTART is used unless you use siginterrupt()
to indicate otherwise for specific signals.

I've also noticed that the I/O routines in a68g-io.c count EINTR
events using a global variable (that is never reset to zero). Once
it hits 256, they start reporting interruptions.

If you had some interrupt happening every 5 seconds, it would take
about 20 minutes to hit 256.

Another finding: genie() calls this:

      (void) a68g_alarm (INTERRUPT_INTERVAL);

INTERRUPT_INTERVAL is 5 seconds. It calls setitimer to start a periodic alarm.

Even if that function were not called, if genie were to receive
a SIGALRM from another process, its handler will call the above function
to set up the interrupt.

So we have proof that genie does sets up a periodic alarm as I suspected
in my first paragraph. The interval does line up with roughly 20
minutes, if we count 256 events as the I/O routines do.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Back to comp.lang.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-04 00:59 +0200
  Re: Interrupted system call on read after ~20 minutes inactivity? scott@slp53.sl.home (Scott Lurndal) - 2025-10-03 23:31 +0000
    Re: Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-04 01:57 +0200
    Re: Interrupted system call on read after ~20 minutes inactivity? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-04 00:28 +0000
      Re: Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-04 02:41 +0200
        Re: Interrupted system call on read after ~20 minutes inactivity? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-04 01:07 +0000
      Re: Interrupted system call on read after ~20 minutes inactivity? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-10-04 01:04 +0000
        Re: Interrupted system call on read after ~20 minutes inactivity? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-04 01:23 +0000
        Re: Interrupted system call on read after ~20 minutes inactivity? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-04 01:28 +0000
          Re: Interrupted system call on read after ~20 minutes inactivity? scott@slp53.sl.home (Scott Lurndal) - 2025-10-04 02:12 +0000
        Re: Interrupted system call on read after ~20 minutes inactivity? Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-04 02:35 +0000
        Re: Interrupted system call on read after ~20 minutes inactivity? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-10-04 12:52 +0000
          Re: Interrupted system call on read after ~20 minutes inactivity? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-04 18:50 +0000
  Re: Interrupted system call on read after ~20 minutes inactivity? Alan Bawden <alan@csail.mit.edu> - 2025-10-03 19:33 -0400
    Re: Interrupted system call on read after ~20 minutes inactivity? Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-03 23:54 +0000
    Re: Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-04 02:00 +0200
      Re: Interrupted system call on read after ~20 minutes inactivity? Alan Bawden <alan@csail.mit.edu> - 2025-10-03 20:26 -0400
        Re: Interrupted system call on read after ~20 minutes inactivity? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-10-05 11:39 +0000
          Re: Interrupted system call on read after ~20 minutes inactivity? Alan Bawden <alan@csail.mit.edu> - 2025-10-06 04:05 -0400
            Re: Interrupted system call on read after ~20 minutes inactivity? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-10-06 10:46 +0000
            Re: Interrupted system call on read after ~20 minutes inactivity? Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-10-06 22:04 +0000
  Re: Interrupted system call on read after ~20 minutes inactivity? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-10-04 00:18 +0000
    Re: Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-04 02:27 +0200
    Re: Interrupted system call on read after ~20 minutes inactivity? scott@slp53.sl.home (Scott Lurndal) - 2025-10-04 02:13 +0000
    Re: Interrupted system call on read after ~20 minutes inactivity? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2025-10-05 11:43 -0700
  Re: Interrupted system call on read after ~20 minutes inactivity? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-10-07 16:29 +0200

csiph-web