Files
mosh/third/libstddjb/sanitize_read.c
T
Quentin Smith 77f3a9073f Import selfpipe code from skalibs 1.2.5
[andersk@mit.edu: Move code to new third/libstddjb directory]
2012-03-07 03:05:37 -05:00

16 lines
270 B
C

/* ISC license. */
#include <errno.h>
#include "allreadwrite.h"
#include "error.h"
int sanitize_read (int r)
{
switch (r)
{
case -1 : return error_isagain(errno) ? (errno = 0, 0) : -1 ;
case 0 : return (errno = EPIPE, -1) ;
default : return r ;
}
}