]> git.sesse.net Git - cubemap/blobdiff - util.cpp
Revert "Rewrite the entire internal signal handling/wakeup."
[cubemap] / util.cpp
index 2bbffdc13c1aeafe0224014060b23043eca47fb1..d6d39f29ada05dc4437886d61178d190df189d02 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -33,7 +33,9 @@ int make_tempfile(const std::string &contents)
                ssize_t ret = write(fd, ptr, to_write);
                if (ret == -1) {
                        log_perror("write");
-                       safe_close(fd);
+                       if (close(fd) == -1) {
+                               log_perror("close");
+                       }
                        return -1;
                }
 
@@ -47,7 +49,17 @@ int make_tempfile(const std::string &contents)
 bool read_tempfile_and_close(int fd, std::string *contents)
 {
        bool ok = read_tempfile(fd, contents);
-       safe_close(fd);  // Implicitly deletes the file.
+
+       int ret;
+       do {
+               ret = close(fd);  // Implicitly deletes the file.
+       } while (ret == -1 && errno == EINTR);
+       
+       if (ret == -1) {
+               log_perror("close");
+               // Can still continue.
+       }
+
        return ok;
 }
 
@@ -84,17 +96,3 @@ bool read_tempfile(int fd, std::string *contents)
 
        return true;
 }
-
-int safe_close(int fd)
-{
-       int ret;
-       do {
-               ret = close(fd);
-       } while (ret == -1 && errno == EINTR);
-
-       if (ret == -1) {
-               log_perror("close()");
-       }
-
-       return ret;
-}