Skip to content

Commit

Permalink
Copy time_to_sleep to time_remaining since it can be left
Browse files Browse the repository at this point in the history
uninitialized if nanosleep returns early with agr error
  • Loading branch information
Andrey A. Chernov authored and Andrey A. Chernov committed Oct 16, 1997
1 parent 987f569 commit 855a496
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/libc/gen/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sleep(seconds)
if (seconds != 0) {
time_to_sleep.tv_sec = seconds;
time_to_sleep.tv_nsec = 0;
time_remaining = time_to_sleep;
(void)nanosleep(&time_to_sleep, &time_remaining);
seconds = time_remaining.tv_sec;
if (time_remaining.tv_nsec > 0)
Expand Down

0 comments on commit 855a496

Please sign in to comment.