2 * copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
7 #pragma ident "%Z%%M% %I% %E% SMI"
12 #define setvec(vec, a) \
13 vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
17 static void sleepx(void);
23 struct itimerval itv
, oitv
;
24 struct itimerval
*itp
= &itv
;
25 struct sigvec vec
, ovec
;
29 timerclear(&itp
->it_interval
);
30 timerclear(&itp
->it_value
);
31 if (setitimer(ITIMER_REAL
, itp
, &oitv
) < 0)
33 itp
->it_value
.tv_sec
= n
;
34 if (timerisset(&oitv
.it_value
)) {
35 if (timercmp(&oitv
.it_value
, &itp
->it_value
, >))
36 oitv
.it_value
.tv_sec
-= itp
->it_value
.tv_sec
;
38 itp
->it_value
= oitv
.it_value
;
40 * This is a hack, but we must have time to
41 * return from the setitimer after the alarm
42 * or else it'll be restarted. And, anyway,
43 * sleep never did anything more than this before.
45 oitv
.it_value
.tv_sec
= 1;
46 oitv
.it_value
.tv_usec
= 0;
50 (void) sigvec(SIGALRM
, &vec
, &ovec
);
51 omask
= sigblock(sigmask(SIGALRM
));
53 (void) setitimer(ITIMER_REAL
, itp
, (struct itimerval
*)0);
55 sigpause(omask
&~ sigmask(SIGALRM
));
56 (void) sigvec(SIGALRM
, &ovec
, (struct sigvec
*)0);
57 (void) sigsetmask(omask
);
58 (void) setitimer(ITIMER_REAL
, &oitv
, (struct itimerval
*)0);