lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 29 Aug 2011 23:13:04 +0200
From:	fogobogo <fogobogo@...hlinux.us>
To:	linux-kernel@...r.kernel.org
Subject: How to use CLOCK_REALTIME_ALARM

Hi!

Since alarmtimers have been mainlined there are now 2 new clock id's, 
CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM which are supposed to wake 
up a machine from suspend too. It's roughly outlined here:

http://lwn.net/Articles/429925/

Now me residing in userspace wonder how to use those. It's the first 
time I try to use a kernel interface and it is quite possible the 
problem is on my end but I have no clue what might be wrong. Here is 
some barely working code:

#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <time.h>

void
func()
{
     printf("pong.\n");
}

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

     struct itimerspec A;
     struct sigevent se;

     int rc; /* return code */

     se.sigev_notify = SIGEV_THREAD;
     se.sigev_notify_function = func;
     se.sigev_notify_attributes = NULL;

     /* doesn't accept CLOCK_REALTIME_ALARM */
     rc = timer_create(CLOCK_REALTIME, &se, &id);
     printf("%d\n",rc);

     /* the only place that seems to actually accept it */
     clock_gettime(CLOCK_REALTIME_ALARM, &A.it_value);

     A.it_value.tv_sec += 10;

     A.it_interval.tv_sec = 0;
     A.it_interval.tv_nsec = 0;

     /* set timer */
     rc = timer_settime(&id, TIMER_ABSTIME, &A, 0);
     printf("%d\n",rc);

     printf("ping.\n");

     /* bad. bad. bad. */
     while(1);

     return 0;
}

I'd appreciate if someone could point me on what I'm doing wrong or tell 
me if the new clock id's work at all.

please CC answers. thanks in advance.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ