diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2021-07-02 17:16:21 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2021-07-02 17:16:21 +0000 |
commit | 18edd7611c6b7d48c6d999f20b0cdde1d6a9e062 (patch) | |
tree | c2c72a0ad1f808425f2d6d95da0c90019dab0261 /lib/libc/gen | |
parent | 259ec9d4995476169c9196936f8ca007bbb4c0e1 (diff) |
usleep(3): always call nanosleep(2)
usleep(3) is a wrapper around nanosleep(2). We should always call
nanosleep(), even if the input is zero. This makes behavior easier
to reason about and ensures we get a nanosleep() ktrace hit if a
program calls usleep().
ok millert@
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/usleep.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 5e2c51464ea..a0c431a83be 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usleep.c,v 1.10 2005/08/08 08:05:34 espie Exp $ */ +/* $OpenBSD: usleep.c,v 1.11 2021/07/02 17:16:20 cheloha Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -37,11 +37,8 @@ usleep(useconds_t useconds) { struct timespec rqt; - if (useconds == 0) - return(0); - rqt.tv_sec = useconds / 1000000; rqt.tv_nsec = (useconds % 1000000) * 1000; - return(nanosleep(&rqt, NULL)); + return nanosleep(&rqt, NULL); } |