2021-08-10 08:55:48 +00:00
|
|
|
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
|
2024-05-16 21:24:04 +00:00
|
|
|
index 56dc1f856..011ec2700 100644
|
2021-08-10 08:55:48 +00:00
|
|
|
--- a/lib/commands/toolcontext.c
|
|
|
|
+++ b/lib/commands/toolcontext.c
|
2024-05-16 21:24:04 +00:00
|
|
|
@@ -1660,6 +1660,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
2021-08-10 08:55:48 +00:00
|
|
|
/* FIXME Make this configurable? */
|
|
|
|
reset_lvm_errno(1);
|
|
|
|
|
2024-05-16 21:24:04 +00:00
|
|
|
+#ifdef __GLIBC__
|
2021-08-10 08:55:48 +00:00
|
|
|
/* Set in/out stream buffering before glibc */
|
|
|
|
if (set_buffering
|
2024-05-16 21:24:04 +00:00
|
|
|
&& !cmd->running_on_valgrind /* Skipping within valgrind execution. */
|
|
|
|
@@ -1704,7 +1705,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
|
|
|
} else if (!set_buffering)
|
|
|
|
/* Without buffering, must not use stdin/stdout */
|
|
|
|
init_silent(1);
|
|
|
|
-
|
|
|
|
+#endif
|
|
|
|
/*
|
|
|
|
* Environment variable LVM_SYSTEM_DIR overrides this below.
|
|
|
|
*/
|
|
|
|
@@ -2038,6 +2039,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|
|
|
if (cmd->cft_def_hash)
|
2023-02-21 23:55:08 +00:00
|
|
|
dm_hash_destroy(cmd->cft_def_hash);
|
2021-08-10 08:55:48 +00:00
|
|
|
|
2024-05-16 21:24:04 +00:00
|
|
|
+#ifdef __GLIBC__
|
|
|
|
if (!cmd->running_on_valgrind && cmd->linebuffer) {
|
|
|
|
int flags;
|
2021-08-10 08:55:48 +00:00
|
|
|
/* Reset stream buffering to defaults */
|
2024-05-16 21:24:04 +00:00
|
|
|
@@ -2061,6 +2063,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|
|
|
|
|
|
|
free(cmd->linebuffer);
|
|
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
destroy_config_context(cmd);
|
|
|
|
|
2021-08-10 08:55:48 +00:00
|
|
|
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
|
2024-05-16 21:24:04 +00:00
|
|
|
index 1b2f7f47c..e0674d42d 100644
|
2021-08-10 08:55:48 +00:00
|
|
|
--- a/tools/lvmcmdline.c
|
|
|
|
+++ b/tools/lvmcmdline.c
|
2024-05-16 21:24:04 +00:00
|
|
|
@@ -3378,7 +3378,7 @@ static int _check_standard_fds(void)
|
2021-08-10 08:55:48 +00:00
|
|
|
int err = is_valid_fd(STDERR_FILENO);
|
|
|
|
|
|
|
|
if (!is_valid_fd(STDIN_FILENO) &&
|
|
|
|
- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
|
|
|
|
+ !freopen(_PATH_DEVNULL, "r", stdin)) {
|
|
|
|
if (err)
|
|
|
|
perror("stdin stream open");
|
|
|
|
else
|
2024-05-16 21:24:04 +00:00
|
|
|
@@ -3388,7 +3388,7 @@ static int _check_standard_fds(void)
|
2021-08-10 08:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_valid_fd(STDOUT_FILENO) &&
|
|
|
|
- !(stdout = fopen(_PATH_DEVNULL, "w"))) {
|
|
|
|
+ !freopen(_PATH_DEVNULL, "w", stdout)) {
|
|
|
|
if (err)
|
|
|
|
perror("stdout stream open");
|
|
|
|
/* else no stdout */
|
2024-05-16 21:24:04 +00:00
|
|
|
@@ -3396,7 +3396,7 @@ static int _check_standard_fds(void)
|
2021-08-10 08:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_valid_fd(STDERR_FILENO) &&
|
|
|
|
- !(stderr = fopen(_PATH_DEVNULL, "w"))) {
|
|
|
|
+ !freopen(_PATH_DEVNULL, "w", stderr)) {
|
|
|
|
printf("stderr stream open: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return 0;
|