Skip to content

Commit

Permalink
Merge pull request #630 from awiddersheim/fix/cleanup_temp_file
Browse files Browse the repository at this point in the history
Attempt to cleanup temp file after error
  • Loading branch information
jrossi committed Jun 25, 2015
2 parents 667ad82 + 5c9964d commit ce48521
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/shared/file_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,26 @@ int mkstemp_ex(char *tmp_path)

/* mkstemp() only implicitly does this in POSIX 2008 */
if (fchmod(fd, 0600) == -1) {
log2file(CHMOD_ERROR, __local_name, tmp_path, errno, strerror(errno));
close(fd);

log2file(
CHMOD_ERROR,
__local_name,
tmp_path,
errno,
strerror(errno)
);

if (unlink(tmp_path)) {
log2file(
DELETE_ERROR,
__local_name,
tmp_path,
errno,
strerror(errno)
);
}

return (-1);
}

Expand Down

0 comments on commit ce48521

Please sign in to comment.