From: Lennart Poettering Date: Wed, 17 Oct 2018 18:14:51 +0000 (+0200) Subject: exec-util: use fflush_and_check() where appropriate X-Git-Tag: v240~529^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c93d527f46070c0603a268408e8a24c924b4f95b;p=thirdparty%2Fsystemd.git exec-util: use fflush_and_check() where appropriate --- diff --git a/src/basic/exec-util.c b/src/basic/exec-util.c index aa26902a20c..32c64184822 100644 --- a/src/basic/exec-util.c +++ b/src/basic/exec-util.c @@ -268,8 +268,8 @@ static int gather_environment_generate(int fd, void *arg) { } static int gather_environment_collect(int fd, void *arg) { - char ***env = arg; _cleanup_fclose_ FILE *f = NULL; + char ***env = arg; int r; /* Write out a series of env=cescape(VAR=value) assignments to fd. */ @@ -286,8 +286,9 @@ static int gather_environment_collect(int fd, void *arg) { if (r < 0) return r; - if (ferror(f)) - return errno > 0 ? -errno : -EIO; + r = fflush_and_check(f); + if (r < 0) + return r; return 0; }