12633Sahl /*
22633Sahl * CDDL HEADER START
32633Sahl *
42633Sahl * The contents of this file are subject to the terms of the
52633Sahl * Common Development and Distribution License (the "License").
62633Sahl * You may not use this file except in compliance with the License.
72633Sahl *
82633Sahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92633Sahl * or http://www.opensolaris.org/os/licensing.
102633Sahl * See the License for the specific language governing permissions
112633Sahl * and limitations under the License.
122633Sahl *
132633Sahl * When distributing Covered Code, include this CDDL HEADER in each
142633Sahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152633Sahl * If applicable, add the following below this CDDL HEADER, with the
162633Sahl * fields enclosed by brackets "[]" replaced with your own identifying
172633Sahl * information: Portions Copyright [yyyy] [name of copyright owner]
182633Sahl *
192633Sahl * CDDL HEADER END
202633Sahl */
212633Sahl
222633Sahl /*
23*3944Sahl * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
242633Sahl * Use is subject to license terms.
252633Sahl */
262633Sahl
272633Sahl #pragma ident "%Z%%M% %I% %E% SMI"
282633Sahl
292633Sahl #include <signal.h>
302633Sahl #include <time.h>
312633Sahl #include <stdlib.h>
322633Sahl #include <stdio.h>
332633Sahl #include <errno.h>
342633Sahl #include <string.h>
352633Sahl
36*3944Sahl int
main(int argc,char ** argv)372633Sahl main(int argc, char **argv)
382633Sahl {
392633Sahl struct sigevent ev;
402633Sahl struct itimerspec ts;
412633Sahl sigset_t set;
422633Sahl timer_t tid;
432633Sahl char *cmd = argv[0];
442633Sahl
452633Sahl ev.sigev_notify = SIGEV_SIGNAL;
462633Sahl ev.sigev_signo = SIGUSR1;
472633Sahl
482633Sahl if (timer_create(CLOCK_REALTIME, &ev, &tid) == -1) {
492633Sahl (void) fprintf(stderr, "%s: cannot create CLOCK_HIGHRES "
502633Sahl "timer: %s\n", cmd, strerror(errno));
512633Sahl exit(EXIT_FAILURE);
522633Sahl }
532633Sahl
542633Sahl (void) sigemptyset(&set);
552633Sahl (void) sigaddset(&set, SIGUSR1);
562633Sahl (void) sigprocmask(SIG_BLOCK, &set, NULL);
572633Sahl
582633Sahl ts.it_value.tv_sec = 1;
592633Sahl ts.it_value.tv_nsec = 0;
602633Sahl ts.it_interval.tv_sec = 0;
612633Sahl ts.it_interval.tv_nsec = NANOSEC / 2;
622633Sahl
632633Sahl if (timer_settime(tid, TIMER_RELTIME, &ts, NULL) == -1) {
642633Sahl (void) fprintf(stderr, "%s: timer_settime() failed: %s\n",
652633Sahl cmd, strerror(errno));
662633Sahl exit(EXIT_FAILURE);
672633Sahl }
682633Sahl
692633Sahl for (;;) {
702633Sahl (void) sigwait(&set);
712633Sahl }
72*3944Sahl
73*3944Sahl /*NOTREACHED*/
74*3944Sahl return (0);
752633Sahl }
76