diff options
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/command.c b/lib/command.c index af6e515ce3..b166d8e0da 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1768,7 +1768,8 @@ DEFUN (config_write, VTY_NEWLINE); goto finished; } - fsync (dirfd); + if (dirfd >= 0) + fsync (dirfd); } if (rename (config_file_tmp, config_file) != 0) { @@ -1776,7 +1777,8 @@ DEFUN (config_write, VTY_NEWLINE); goto finished; } - fsync (dirfd); + if (dirfd >= 0) + fsync (dirfd); vty_out (vty, "Configuration saved to %s%s", config_file, VTY_NEWLINE); @@ -1785,7 +1787,8 @@ DEFUN (config_write, finished: if (ret != CMD_SUCCESS) unlink (config_file_tmp); - close (dirfd); + if (dirfd >= 0) + close (dirfd); XFREE (MTYPE_TMP, config_file_tmp); XFREE (MTYPE_TMP, config_file_sav); return ret; |
