public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mmedon at student dot agh.edu.pl" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug time/28739] New: Timer doesn't send SIGSTOP signal after expiration
Date: Sun, 02 Jan 2022 19:10:10 +0000	[thread overview]
Message-ID: <bug-28739-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=28739

            Bug ID: 28739
           Summary: Timer doesn't send SIGSTOP signal after expiration
           Product: glibc
           Version: 2.34
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: time
          Assignee: unassigned at sourceware dot org
          Reporter: mmedon at student dot agh.edu.pl
  Target Milestone: ---

Timer doesn't send signal (SIGSTOP/SIGTSTP/SIGTTIN/SIGTTOU) when the time
period between timer expiration and SIGCONT delivering is at least two times
longer than value in itimerspec.

Code example:

#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char *argv[]) {


    printf("PID: %d \n", getpid());
    timer_t timer;
    struct sigevent sev;
    sev.sigev_notify = SIGEV_SIGNAL;
    sev.sigev_signo = SIGSTOP;

    struct timespec timeForTimer = {.tv_sec = 10, .tv_nsec = 0};
    struct itimerspec ts = {.it_interval = timeForTimer, .it_value =
timeForTimer};

    if (timer_create(CLOCK_REALTIME, &sev, &timer) == -1) {
        perror("Error in timer_create!\n");
        exit(EXIT_FAILURE);
    }
    if (timer_settime(timer, 0, &ts, NULL) == -1) {
        perror("Error in timer_settime!\n");
        exit(EXIT_FAILURE);
    }

    struct timespec timeToWaitInLoop = {.tv_sec = 5, .tv_nsec = 0};

    for (;;) {
        time_t t = time(NULL);
        struct tm tm = *localtime(&t);
        printf("Time: %02d:%02d:%02d\n", tm.tm_hour, tm.tm_min, tm.tm_sec);
        nanosleep(&timeToWaitInLoop, NULL);
    }


}


Example output:
PID: 19139 
Time: 17:16:54
Time: 17:16:59 <- then SIGSTOP came
Time: 17:17:30 <- then I sent SIGCONT (from bash)
Time: 17:17:35
Time: 17:17:40
Time: 17:17:45
Time: 17:17:50

We should expect next SIGSTOP signal but it never comes
I also have created a thread on unix.stackexchange 
https://unix.stackexchange.com/questions/684192/specific-behavior-of-timers-with-sigev-notify-sigstop-signal

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2022-01-02 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02 19:10 mmedon at student dot agh.edu.pl [this message]
2022-01-02 19:11 ` [Bug time/28739] " mmedon at student dot agh.edu.pl
2022-01-03 19:46 ` fweimer at redhat dot com
2022-06-09 15:18 ` schwab@linux-m68k.org

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

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

  git send-email \
    --in-reply-to=bug-28739-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).