View Single Post
Posts: 99 | Thanked: 65 times | Joined on Jan 2008 @ Finland
#2
Originally Posted by fiferboy View Post
Also, if I try to check what alarms are set in my program using alarmd commands I get a segfault. -- My program crashes every time at the "list=..."
I've only used alarmd in one application so far, but I haven't really had any problems with it. alarm_event_query() works just fine here, compile with gcc -Wall $(pkg-config --libs --cflags libalarm) file.c:

Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <alarmd/alarm_event.h>

int
main(int argc, char **argv)
{
        cookie_t *list, *iter;
        time_t now;

        now = time(NULL);
        list = alarm_event_query(now, now + 60, 0, 0);
        if (list == NULL) {
                fprintf(stderr, "alarm_event_query() failed\n");
                return EXIT_FAILURE;
        }

        if (list[0] == (cookie_t) 0) {
                printf("no alarms set\n");
        } else {
                printf("alarm ids:");
                for (iter = list; *iter != (cookie_t) 0; iter++) {
                        printf(" %u\n", (unsigned int) *iter);
                }
                printf("\n");
        }

        free(list);
        return EXIT_SUCCESS;
}
 

The Following 2 Users Say Thank You to wnd For This Useful Post: