aboutsummaryrefslogtreecommitdiff
path: root/miscutils/crontab.c
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils/crontab.c')
-rw-r--r--miscutils/crontab.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index c71d914fc..411a18a50 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -165,8 +165,12 @@ int crontab_main(int argc UNUSED_PARAM, char **argv)
close(fd);
xlseek(src_fd, 0, SEEK_SET);
}
- close_on_exec_on(src_fd); /* don't want editor to see this fd */
+ close(src_fd);
edit_file(pas, tmp_fname);
+ /* The src_fd needs to be reopened to handle editors that do
+ * save the buffer as new file and rename it to tmp_fname (so
+ * for example vim). */
+ src_fd = xopen3(tmp_fname, O_RDONLY, 0600);
/* fall through */
case 0: /* Replace (no -l, -e, or -r were given) */