public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug time/28739] New: Timer doesn't send SIGSTOP signal after expiration
@ 2022-01-02 19:10 mmedon at student dot agh.edu.pl
  2022-01-02 19:11 ` [Bug time/28739] " mmedon at student dot agh.edu.pl
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mmedon at student dot agh.edu.pl @ 2022-01-02 19:10 UTC (permalink / raw)
  To: glibc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-09 15:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 19:10 [Bug time/28739] New: Timer doesn't send SIGSTOP signal after expiration mmedon at student dot agh.edu.pl
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

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).