From 7efc949d8ed7285fac01a6f6fb10c04b4fbee1a0 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Mon, 27 Sep 2021 12:03:20 +0200 Subject: [PATCH] lxc-monitord: use {} around ; Signed-off-by: Christian Brauner --- src/lxc/cmd/lxc_monitord.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lxc/cmd/lxc_monitord.c b/src/lxc/cmd/lxc_monitord.c index 16a500610..ef90d63ed 100644 --- a/src/lxc/cmd/lxc_monitord.c +++ b/src/lxc/cmd/lxc_monitord.c @@ -397,15 +397,18 @@ int main(int argc, char *argv[]) goto on_error; monitord_created = true; - /* sync with parent, we're ignoring the return from write - * because regardless if it works or not, the following - * close will sync us with the parent process. the - * if-empty-statement construct is to quiet the - * warn-unused-result warning. - */ - if (lxc_write_nointr(pipefd, "S", 1)) - ; - close(pipefd); + if (pipefd != -1) { + /* sync with parent, we're ignoring the return from write + * because regardless if it works or not, the following + * close will sync us with the parent process. the + * if-empty-statement construct is to quiet the + * warn-unused-result warning. + */ + if (lxc_write_nointr(pipefd, "S", 1)) { + ; + } + close(pipefd); + } if (lxc_monitord_mainloop_add(&monitor)) { ERROR("Failed to add mainloop handlers"); -- 2.47.2