aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2014-03-18 17:52:31 -0700
committerNick Mathewson <nickm@torproject.org>2014-03-31 11:27:08 -0400
commitabdf1878a3f8fe366d8bb7f649127880bdbdf82d (patch)
tree047bb6044119bb27a6c19f2452409063ca9173e7 /src/or/main.c
parentdf076eccfaa680ee08b8ae866690d9a2a8ba5555 (diff)
downloadtor-abdf1878a3f8fe366d8bb7f649127880bdbdf82d.tar.gz
tor-abdf1878a3f8fe366d8bb7f649127880bdbdf82d.zip
Always check returns from unlink()
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 7294c8955a..3d5ce10cfd 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2574,10 +2574,19 @@ tor_cleanup(void)
time_t now = time(NULL);
/* Remove our pid file. We don't care if there was an error when we
* unlink, nothing we could do about it anyways. */
- if (options->PidFile)
- unlink(options->PidFile);
- if (options->ControlPortWriteToFile)
- unlink(options->ControlPortWriteToFile);
+ if (options->PidFile) {
+ if (unlink(options->PidFile) != 0) {
+ log_warn(LD_FS, "Couldn't unlink pid file %s: %s",
+ options->PidFile, strerror(errno));
+ }
+ }
+ if (options->ControlPortWriteToFile) {
+ if (unlink(options->ControlPortWriteToFile) != 0) {
+ log_warn(LD_FS, "Couldn't unlink control port file %s: %s",
+ options->ControlPortWriteToFile,
+ strerror(errno));
+ }
+ }
if (accounting_is_enabled(options))
accounting_record_bandwidth_usage(now, get_or_state());
or_state_mark_dirty(get_or_state(), 0); /* force an immediate save. */