Do not fsync descriptor referred to a tty (#3785)

When transmission-daemon is running with '--foreground' option,
log messages are emitted to standard error, which may be referred
to a tty. Since an attempt to fsync() tty is always an error,
an extra isatty() precaution should be applied.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
This commit is contained in:
Dmitry Antipov 2022-09-07 21:44:31 +03:00 committed by GitHub
parent 806a6382d7
commit 2bcb8f8535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -781,7 +781,7 @@ bool tr_sys_file_flush(tr_sys_file_t handle, tr_error** error)
{
TR_ASSERT(handle != TR_BAD_SYS_FILE);
bool const ret = fsync(handle) != -1;
bool const ret = (isatty(handle) ? true : (fsync(handle) != -1));
if (!ret)
{