summaryrefslogtreecommitdiff
path: root/src/wallpaper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallpaper.c')
-rw-r--r--src/wallpaper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 9df259f..96b4f90 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -452,6 +452,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
home = getenv("HOME");
if (home) {
FILE *fp;
+ int fd;
char *path;
char *absolute_path;
struct stat s;
@@ -519,11 +520,11 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
free(absolute_path);
}
fputc('\n', fp);
- fclose(fp);
- stat(path, &s);
- if (chmod(path, s.st_mode | S_IXUSR | S_IXGRP) != 0) {
+ fd = fileno(fp);
+ if (fstat(fd, &s) != 0 || fchmod(fd, s.st_mode | S_IXUSR | S_IXGRP) != 0) {
weprintf("Can't set %s as executable", path);
}
+ fclose(fp);
}
free(path);
}