1 /* $NetBSD: h_sigcli.c,v 1.3 2011/02/07 20:05:09 pooka Exp $ */
4 #include <sys/sysctl.h>
12 #include <rump/rump_syscalls.h>
13 #include <rump/rumpclient.h>
15 static const int hostnamemib
[] = { CTL_KERN
, KERN_HOSTNAME
};
16 static char hostnamebuf
[128];
18 static volatile sig_atomic_t sigexecs
;
24 size_t blen
= sizeof(buf
);
26 if (rump_sys___sysctl(hostnamemib
, __arraycount(hostnamemib
),
27 buf
, &blen
, NULL
, 0) == -1)
28 err(1, "sighand sysctl");
29 if (strcmp(buf
, hostnamebuf
) != 0)
30 errx(1, "sighandler hostname");
44 if (rumpclient_init() == -1)
45 err(1, "rumpclient init");
47 hnbsize
= sizeof(hostnamebuf
);
48 if (rump_sys___sysctl(hostnamemib
, __arraycount(hostnamemib
),
49 hostnamebuf
, &hnbsize
, NULL
, 0) == -1)
52 if (signal(SIGALRM
, sighand
) == SIG_ERR
)
55 itv
.it_interval
.tv_sec
= itv
.it_value
.tv_sec
= 0;
56 itv
.it_interval
.tv_usec
= itv
.it_value
.tv_usec
= 10000; /* 10ms */
58 if (setitimer(ITIMER_REAL
, &itv
, NULL
) == -1)
64 if (rump_sys___sysctl(hostnamemib
, __arraycount(hostnamemib
),
65 buf
, &blen
, NULL
, 0) == -1)
67 if (strcmp(buf
, hostnamebuf
) != 0)
68 errx(1, "main hostname");
71 * check every 100 cycles to avoid doing
72 * nothing but gettimeofday()
75 if (time(NULL
) - tstart
> 5)
82 printf("no signal handlers run. test busted?\n");