status = unpacker(&info);
if (status < 0)
exitcode = 1;
+ xclose(STDOUT_FILENO); /* with error check! */
if (filename) {
char *del = new_name;
times.actime = info.mtime;
times.modtime = info.mtime;
- /* Close first.
+ /* Note: we closed it first.
* On some systems calling utime
- * then closing resets the mtime. */
- close(STDOUT_FILENO);
- /* Ignoring errors */
- utime(new_name, ×);
+ * then closing resets the mtime
+ * back to current time. */
+ utime(new_name, ×); /* ignoring errors */
}
/* Delete _compressed_ file */
extern void xwrite_str(int fd, const char *str) FAST_FUNC;
extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC;
+/* Close fd, but check for failures (some types of write errors) */
+extern void xclose(int fd) FAST_FUNC;
+
/* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
extern void xprint_and_close_file(FILE *file) FAST_FUNC;
xwrite(fd, str, strlen(str));
}
+void FAST_FUNC xclose(int fd)
+{
+ if (close(fd))
+ bb_perror_msg_and_die("close failed");
+}
+
// Die with an error message if we can't lseek to the right spot.
off_t FAST_FUNC xlseek(int fd, off_t offset, int whence)
{