From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4421 invoked by alias); 24 Feb 2019 06:58:52 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 4405 invoked by uid 89); 24 Feb 2019 06:58:51 -0000 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 Received: from sonic312-24.consmr.mail.gq1.yahoo.com (HELO sonic312-24.consmr.mail.gq1.yahoo.com) (98.137.69.205) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 24 Feb 2019 06:58:49 +0000 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== Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.gq1.yahoo.com with HTTP; Sun, 24 Feb 2019 06:58:47 +0000 Received: from 75-54-112-187.lightspeed.irvnca.sbcglobal.net (EHLO joshua.dnsalias.com) ([75.54.112.187]) by smtp427.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID a891855296b3983227b6a1fc6b40fec2 for ; Sun, 24 Feb 2019 06:58:43 +0000 (UTC) Date: Sun, 24 Feb 2019 09:15:00 -0000 From: "Mike Gran via cygwin" Reply-To: Mike Gran To: cygwin@cygwin.com Subject: return value of getitimer after an alarm Message-ID: <20190224065837.GA14582@joshua.dnsalias.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes X-SW-Source: 2019-02/txt/msg00396.txt.bz2 --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 400 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" Content-length: 1016 #include #include #include #include #include #include #include #include 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 Content-length: 219 -- 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--