mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
commandhelper: Consolidate argument parsing
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
8d57776702
commit
9668fd8ebf
@ -66,6 +66,7 @@ int main(int argc, char **argv) {
|
|||||||
size_t buflen[3] = {0, 0, 0};
|
size_t buflen[3] = {0, 0, 0};
|
||||||
char c;
|
char c;
|
||||||
bool daemonize_check = false;
|
bool daemonize_check = false;
|
||||||
|
bool close_stdin = false;
|
||||||
size_t daemonize_retries = 3;
|
size_t daemonize_retries = 3;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
ssize_t got;
|
ssize_t got;
|
||||||
@ -82,6 +83,8 @@ int main(int argc, char **argv) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (STREQ(argv[i], "--check-daemonize")) {
|
} else if (STREQ(argv[i], "--check-daemonize")) {
|
||||||
daemonize_check = true;
|
daemonize_check = true;
|
||||||
|
} else if (STREQ(argv[i], "--close-stdin")) {
|
||||||
|
close_stdin = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
fprintf(log, "UMASK:%04o\n", umask(0));
|
fprintf(log, "UMASK:%04o\n", umask(0));
|
||||||
|
|
||||||
if (argc > 1 && STREQ(argv[1], "--close-stdin")) {
|
if (close_stdin) {
|
||||||
if (freopen("/dev/null", "r", stdin) != stdin)
|
if (freopen("/dev/null", "r", stdin) != stdin)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
usleep(100*1000);
|
usleep(100*1000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user