2019-06-22 23:56:28 -06:00
|
|
|
--- ./tools/lvmcmdline.c
|
|
|
|
+++ ./tools/lvmcmdline.c
|
|
|
|
@@ -1252,7 +1252,7 @@
|
|
|
|
int err = is_valid_fd(STDERR_FILENO);
|
2019-09-03 13:13:08 -06:00
|
|
|
|
2019-06-22 23:56:28 -06:00
|
|
|
if (!is_valid_fd(STDIN_FILENO) &&
|
|
|
|
- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
|
|
|
|
+ !freopen(_PATH_DEVNULL, "r", stdin)) {
|
|
|
|
if (err)
|
|
|
|
perror("stdin stream open");
|
|
|
|
else
|
|
|
|
@@ -1262,7 +1262,7 @@
|
|
|
|
}
|
2019-09-03 13:13:08 -06:00
|
|
|
|
2019-06-22 23:56:28 -06: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 */
|
|
|
|
@@ -1270,7 +1270,7 @@
|
|
|
|
}
|
2019-09-03 13:13:08 -06:00
|
|
|
|
2019-06-22 23:56:28 -06: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;
|
2019-09-03 13:13:08 -06:00
|
|
|
--- a/lib/commands/toolcontext.c
|
|
|
|
+++ b/lib/commands/toolcontext.c
|
|
|
|
@@ -1649,7 +1649,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
|
|
|
|
/* FIXME Make this configurable? */
|
|
|
|
reset_lvm_errno(1);
|
|
|
|
|
2019-06-22 23:56:28 -06:00
|
|
|
-#ifndef VALGRIND_POOL
|
2019-09-03 13:13:08 -06:00
|
|
|
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
|
|
|
|
/* Set in/out stream buffering before glibc */
|
|
|
|
if (set_buffering
|
2019-06-22 23:56:28 -06:00
|
|
|
#ifdef SYS_gettid
|
2019-09-03 13:13:08 -06:00
|
|
|
@@ -2031,7 +2031,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|
|
|
if (cmd->libmem)
|
|
|
|
dm_pool_destroy(cmd->libmem);
|
|
|
|
|
2019-06-22 23:56:28 -06:00
|
|
|
-#ifndef VALGRIND_POOL
|
2019-09-03 13:13:08 -06:00
|
|
|
+#if defined(__GLIBC__) && !defined(VALGRIND_POOL)
|
|
|
|
if (cmd->linebuffer) {
|
|
|
|
/* Reset stream buffering to defaults */
|
|
|
|
if (is_valid_fd(STDIN_FILENO) &&
|
|
|
|
--- a/tools/lvmcmdline.c
|
|
|
|
+++ b/tools/lvmcmdline.c
|
|
|
|
@@ -3055,6 +3055,7 @@ int lvm_split(char *str, int *argc, char **argv, int max)
|
|
|
|
/* Make sure we have always valid filedescriptors 0,1,2 */
|
|
|
|
static int _check_standard_fds(void)
|
|
|
|
{
|
|
|
|
+#ifdef __GLIBC__
|
|
|
|
int err = is_valid_fd(STDERR_FILENO);
|
|
|
|
|
|
|
|
if (!is_valid_fd(STDIN_FILENO) &&
|
|
|
|
@@ -3081,6 +3082,12 @@ static int _check_standard_fds(void)
|
|
|
|
strerror(errno));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
+#else
|
|
|
|
+ if (!is_valid_fd(STDERR_FILENO) ||
|
|
|
|
+ !is_valid_fd(STDOUT_FILENO) ||
|
|
|
|
+ !is_valid_fd(STDIN_FILENO))
|
|
|
|
+ return 0;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|