projects
/
unix-history
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
BSD 4_1c_2 release
[unix-history]
/
usr
/
src
/
lib
/
libc
/
gen
/
sleep.c
/* @(#)sleep.c 4.1 (Berkeley) 12/21/80 */
#include <signal.h>
#include <setjmp.h>
static jmp_buf
jmp
;
sleep
(
n
)
unsigned
n
;
{
int
sleepx
();
unsigned
altime
;
int
(*
alsig
)() =
SIG_DFL
;
if
(
n
==
0
)
return
;
altime
=
alarm
(
1000
);
/* time to maneuver */
if
(
setjmp
(
jmp
)) {
signal
(
SIGALRM
,
alsig
);
alarm
(
altime
);
return
;
}
if
(
altime
) {
if
(
altime
>
n
)
altime
-=
n
;
else
{
n
=
altime
;
altime
=
1
;
}
}
alsig
=
signal
(
SIGALRM
,
sleepx
);
alarm
(
n
);
for
(;;)
pause
();
/*NOTREACHED*/
}
static
sleepx
()
{
longjmp
(
jmp
,
1
);
}