[lxc-devel] [lxd/master] main_forkdns: Restores usage output text when running with no arguments
tomponline on Github
lxc-bot at linuxcontainers.org
Wed Jun 12 08:29:42 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 556 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190612/1355e002/attachment.bin>
-------------- next part --------------
From a424fbfe3ac51c727ab6e1b7488fe15003d9abc1 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 12 Jun 2019 09:22:48 +0100
Subject: [PATCH 1/2] main_forkdns: Restores usage output text when running
with no arguments
stgraber emphasised the use of the usage text when running the program here https://github.com/lxc/lxd/pull/5817#discussion_r291122104
This change restores access to it when running without any arguments.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/main_forkdns.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lxd/main_forkdns.go b/lxd/main_forkdns.go
index 049d283a8b..e79d8ba77e 100644
--- a/lxd/main_forkdns.go
+++ b/lxd/main_forkdns.go
@@ -66,7 +66,13 @@ void forkdns()
close(STDIN_FILENO);
- log_path = advance_arg(true);
+ log_path = advance_arg(false);
+ pid_path = advance_arg(false);
+
+ // If arguments are missing, fall through to Go part without double forking to output usage info.
+ if (log_path == NULL || pid_path == NULL)
+ return;
+
log_fd = open(log_path, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0600);
if (log_fd < 0)
_exit(EXIT_FAILURE);
@@ -79,7 +85,6 @@ void forkdns()
if (ret < 0)
_exit(EXIT_FAILURE);
- pid_path = advance_arg(true);
pid_file = fopen(pid_path, "we+");
if (!pid_file) {
fprintf(stderr,
From 5d374966e4fa28a5abd0bc6bfee5bbf73121117a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 12 Jun 2019 09:28:16 +0100
Subject: [PATCH 2/2] main_forkdns: Removes unused includes
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/main_forkdns.go | 5 -----
1 file changed, 5 deletions(-)
diff --git a/lxd/main_forkdns.go b/lxd/main_forkdns.go
index e79d8ba77e..e339593c49 100644
--- a/lxd/main_forkdns.go
+++ b/lxd/main_forkdns.go
@@ -25,14 +25,9 @@ import (
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/epoll.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
More information about the lxc-devel
mailing list