# HG changeset patch # User Rob Landley # Date 1375895991 18000 # Node ID 252caf3d2b88c908b446ef54c7f5bab54b04e4ab # Parent 8caeba551a28d864bc93f46b969cb6c5e3fb7561 Forgot to check in xfdopen(). My bad. Failure of fdopen() is most likely failure of malloc() for the FILE structure. diff -r 8caeba551a28 -r 252caf3d2b88 lib/lib.h --- a/lib/lib.h Wed Aug 07 11:51:26 2013 -0500 +++ b/lib/lib.h Wed Aug 07 12:19:51 2013 -0500 @@ -106,6 +106,7 @@ int xopen(char *path, int flags); void xclose(int fd); int xdup(int fd); +FILE *xfdopen(int fd, char *mode); FILE *xfopen(char *path, char *mode); size_t xread(int fd, void *buf, size_t len); void xreadall(int fd, void *buf, size_t len); diff -r 8caeba551a28 -r 252caf3d2b88 lib/xwrap.c --- a/lib/xwrap.c Wed Aug 07 11:51:26 2013 -0500 +++ b/lib/xwrap.c Wed Aug 07 12:19:51 2013 -0500 @@ -172,6 +172,15 @@ return fd; } +FILE *xfdopen(int fd, char *mode) +{ + FILE *f = fdopen(fd, mode); + + if (!f) perror_exit("xfdopen"); + + return f; +} + // Die unless we can open/create a file, returning FILE *. FILE *xfopen(char *path, char *mode) {