diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-08-20 13:45:16 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-08-20 13:45:16 -0400 |
commit | a32913d5aa816cdc41edbabf9b606b83aea6c835 (patch) | |
tree | b0d4b1b6db1136f4605ef31c14407a23d4080667 /src/common/compat.c | |
parent | fb762f6db0a363349afd83e5316daf613e27e450 (diff) | |
download | tor-a32913d5aa816cdc41edbabf9b606b83aea6c835.tar.gz tor-a32913d5aa816cdc41edbabf9b606b83aea6c835.zip |
Allow named pipes for our log files.
Closes ticket 12061. Based on a patch from "carlo von lynX" on tor-dev at
https://lists.torproject.org/pipermail/tor-dev/2014-April/006705.html
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index c4f5987d5a..eb9a70f580 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -981,14 +981,23 @@ tor_fd_getpos(int fd) #endif } -/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success. */ +/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success. + * If the file is a pipe, do nothing and succeed. + **/ int tor_fd_seekend(int fd) { #ifdef _WIN32 return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0; #else - return lseek(fd, 0, SEEK_END) < 0 ? -1 : 0; + int rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0; +#ifdef ESPIPE + /* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo: + * no need to worry. */ + if (rc < 0 && errno == ESPIPE) + rc = 0; +#endif + return rc; #endif } |