=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/atomicio.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- src/usr.bin/ssh/atomicio.c 2016/07/27 23:18:12 1.28 +++ src/usr.bin/ssh/atomicio.c 2019/01/23 08:01:46 1.29 @@ -1,4 +1,4 @@ -/* $OpenBSD: atomicio.c,v 1.28 2016/07/27 23:18:12 djm Exp $ */ +/* $OpenBSD: atomicio.c,v 1.29 2019/01/23 08:01:46 dtucker Exp $ */ /* * Copyright (c) 2006 Damien Miller. All rights reserved. * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. @@ -54,9 +54,15 @@ res = (f) (fd, s + pos, n - pos); switch (res) { case -1: - if (errno == EINTR) + switch(errno) { + case EINTR: + /* possible SIGALARM, update callback */ + if (cb != NULL && cb(cb_arg, 0) == -1) { + errno = EINTR; + return pos; + } continue; - if (errno == EAGAIN) { + case EAGAIN: (void)poll(&pfd, 1, -1); continue; } @@ -107,9 +113,15 @@ res = (f) (fd, iov, iovcnt); switch (res) { case -1: - if (errno == EINTR) + switch(errno) { + case EINTR: + /* possible SIGALARM, update callback */ + if (cb != NULL && cb(cb_arg, 0) == -1) { + errno = EINTR; + return pos; + } continue; - if (errno == EAGAIN) { + case EAGAIN: (void)poll(&pfd, 1, -1); continue; }