zos: fix return value on expired nanosleep() call

In the emulated nanosleep() function on z/OS an EAGAIN error from
BPX1CTW/BPX4CTW indicates that the timeout has expired. In that
case return 0 and not -1.

PR-URL: https://github.com/libuv/libuv/pull/2737
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Richard Lau 2020-03-17 17:28:50 -04:00
parent a9c58e72a3
commit 875a4fe653
No known key found for this signature in database
GPG Key ID: C43CEC45C17AB93C

View File

@ -408,10 +408,12 @@ int nanosleep(const struct timespec* req, struct timespec* rem) {
* Don't leak EAGAIN, that just means the timeout expired.
*/
if (rv == -1)
if (err != EAGAIN)
if (err == EAGAIN)
rv = 0;
else
errno = err;
if (rem != NULL && (rv == 0 || err == EINTR || err == EAGAIN)) {
if (rem != NULL && (rv == 0 || err == EINTR)) {
rem->tv_nsec = nanorem;
rem->tv_sec = secrem;
}