diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-08-20 23:24:19 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2010-08-20 23:24:19 +0200 |
commit | f5c598b518d1f906148534d015f50075d3e8242d (patch) | |
tree | 21dd70add5b366c3dd80641b77f6b18e0baa009e /dpid/dpid_common.c | |
parent | e98d02a01ffeb18ede86af025e51ae1ec011c75a (diff) | |
parent | 5f0fc0e48b8cbee7e1795935da0abff6627fd498 (diff) |
merge
Diffstat (limited to 'dpid/dpid_common.c')
-rw-r--r-- | dpid/dpid_common.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/dpid/dpid_common.c b/dpid/dpid_common.c index a04d9c4f..a903db95 100644 --- a/dpid/dpid_common.c +++ b/dpid/dpid_common.c @@ -1,5 +1,16 @@ +/* + * File: dpid_common.c + * + * Copyright 2008 Jorge Arellano Cid <jcid@dillo.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + */ + +#include <errno.h> #include <stdio.h> -#include <string.h> #include <unistd.h> #include "dpid_common.h" @@ -41,3 +52,22 @@ ssize_t ckd_write(int fd, char *msg, char *file, int line) } return (ret); } + +/*! + * Provides an error checked close() call. + * Call this via the CKD_CLOSE macro + * \return close return value + */ +ssize_t ckd_close(int fd, char *file, int line) +{ + ssize_t ret; + + do { + ret = close(fd); + } while (ret == -1 && errno == EINTR); + if (ret == -1) { + MSG_ERR("%s:%d: close: %s\n", file, line, dStrerror(errno)); + } + return (ret); +} + |