delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/02/24/02:00:02

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:to:subject:message-id
:mime-version:content-type; q=dns; s=default; b=H7Vm4SH1YtPKQSub
hz9Qs4A98ln/EwsLuPfdty3m6uv709+h8u2x5M7yjZF10EYJGqpmYsn4RSrFeF50
HOKXA5UkVuJiLD7AAHYxT6/G/gu09T03f2OD+xvNRzz8M9+pfA0YghBS2KYLgVKj
97VFlB/CEMjaKzLb0tImVeeN2Ns=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:reply-to:to:subject:message-id
:mime-version:content-type; s=default; bh=cHSqou/Z7O0hUa+++c+l9Z
0ANdM=; b=LG2eYOmqZUT0Ktx7Yt0jNwSc+CFBfEtyeTin1MrB3JhNel5Q82Bl53
zOKega/udIg2nqwFUiWV0Tc0Qnz3wT8/XeiOahmTvH1FJLCDmQy2gABtOpTVQSCb
xf2thrOu2yK/AAy7Dy7eEdRfOR5i5zptwubwZZHh13xOJ3nEXA0HQ=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=gran, alarm, Loop, H*F:D*yahoo.com
X-HELO: sonic312-24.consmr.mail.gq1.yahoo.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1550991527; bh=d6D5MN8OZa0PaGScwf7iD7yhi8aKeA6BHMfAwbRg6vk=; h=Date:From:To:Subject:From:Subject; b=JGUS2FLwREu7JgTEAFUHr5rtUIcroAIdmp/oXeUAfXDzcZjQ58d/eTTqEDbJjNvi17zIyCL+x/b7Hxdp3UoOBM2HxHYgayFDT7v+auEZ2kTszJ/CpsR2LEl90K3gYYxT8GNTm6F/uEg6+iMwYyRfZrTvYUCMGbo/KxtlmrLUrhCq6Y4Ggl84QeKdOLbEwzMTmh+B5FCwyrZUCF1vHTCfE9pPU/I6YMPQez+vvEwiHKJLYhzSqXpHaISLPu4bdclqqrGc1ppvG9RyTI9PiuSbpOEsQSWxyewY62MDqqSJ1x1zykktavQhZkxkrgVC5xYxE6Hy0aY9Xjhf2nYEXJ/6JQ==
Date: Sat, 23 Feb 2019 22:58:37 -0800
From: "Mike Gran via cygwin" <cygwin AT cygwin DOT com>
Reply-To: Mike Gran <spk121 AT yahoo DOT com>
To: cygwin AT cygwin DOT com
Subject: return value of getitimer after an alarm
Message-ID: <20190224065837.GA14582@joshua.dnsalias.com>
MIME-Version: 1.0
User-Agent: Mutt/1.10.1 (2018-07-13)
X-IsSubscribed: yes

--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi-

There is an unusual behaviour with setitimer/getitimer and I'm not
sure if it is a bug or not.

Basically, if I call setitimer to set an SIGALRM, and then call
getitimer *after* the alarm goes off, I rather expect the time I
receive from getitimer should be {tv_sec = 0, tv_usec = 0}, but, in
fact, it_value is the negative of the unix timestamp.

Attached is a test case.

Thanks,
Mike Gran




--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="tmp.c"

#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>

int loop = 1;

static void
handler(int sig, siginfo_t *si, void *unused)
{
  printf("Got SIGALRM at address: 0x%lx\n",
	 (long) si->si_addr);
  loop = 0;
}

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

  struct sigaction sa;

  sa.sa_flags = SA_SIGINFO;
  sigemptyset(&sa.sa_mask);
  sa.sa_sigaction = handler;
  sigaction(SIGALRM, &sa, NULL);

  struct itimerval new_value, old_value;
  new_value.it_interval.tv_sec = 0;
  new_value.it_interval.tv_usec = 0;
  new_value.it_value.tv_sec = 0;
  new_value.it_value.tv_usec = 1000;
  setitimer(ITIMER_REAL, &new_value, &old_value);
  while (loop)
    ;
  printf("Loop is complete\n");
  int ret = getitimer(ITIMER_REAL, &old_value);
  printf("%d %ld %ld %ld %ld\n",
	 ret,
	 old_value.it_interval.tv_sec,
	 old_value.it_interval.tv_usec,
	 old_value.it_value.tv_sec,
	 old_value.it_value.tv_usec
	 );

  return 0;
}


--rwEMma7ioTxnRzrJ
Content-Type: text/plain; charset=us-ascii


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--rwEMma7ioTxnRzrJ--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019