projects/aports·blob master · refs

67 lines · 2.0 KiB

1diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
2index 60739af..8b3fdf7 100644
3--- a/lib/commands/toolcontext.c
4+++ b/lib/commands/toolcontext.c
5@@ -1661,6 +1661,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
6 reset_lvm_errno(1);
7
8 /* Set in/out stream buffering before glibc */
9+#ifdef __GLIBC__
10 if (set_buffering
11 && !cmd->running_on_valgrind /* Skipping within valgrind execution. */
12 #ifdef SYS_gettid
13@@ -1704,6 +1705,7 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
14 } else if (!set_buffering)
15 /* Without buffering, must not use stdin/stdout */
16 init_silent(1);
17+#endif
18
19 /*
20 * Environment variable LVM_SYSTEM_DIR overrides this below.
21@@ -2038,6 +2040,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
22 if (cmd->cft_def_hash)
23 dm_hash_destroy(cmd->cft_def_hash);
24
25+#ifdef __GLIBC__
26 if (!cmd->running_on_valgrind && cmd->linebuffer) {
27 int flags;
28 /* Reset stream buffering to defaults */
29@@ -2061,6 +2064,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
30
31 free(cmd->linebuffer);
32 }
33+#endif
34
35 destroy_config_context(cmd);
36
37diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
38index 7209ebd..778c8c0 100644
39--- a/tools/lvmcmdline.c
40+++ b/tools/lvmcmdline.c
41@@ -3378,7 +3378,7 @@ static int _check_standard_fds(void)
42 int err = is_valid_fd(STDERR_FILENO);
43
44 if (!is_valid_fd(STDIN_FILENO) &&
45- !(stdin = fopen(_PATH_DEVNULL, "r"))) {
46+ !freopen(_PATH_DEVNULL, "r", stdin)) {
47 if (err)
48 perror("stdin stream open");
49 else
50@@ -3388,7 +3388,7 @@ static int _check_standard_fds(void)
51 }
52
53 if (!is_valid_fd(STDOUT_FILENO) &&
54- !(stdout = fopen(_PATH_DEVNULL, "w"))) {
55+ !freopen(_PATH_DEVNULL, "w", stdout)) {
56 if (err)
57 perror("stdout stream open");
58 /* else no stdout */
59@@ -3396,7 +3396,7 @@ static int _check_standard_fds(void)
60 }
61
62 if (!is_valid_fd(STDERR_FILENO) &&
63- !(stderr = fopen(_PATH_DEVNULL, "w"))) {
64+ !freopen(_PATH_DEVNULL, "w", stderr)) {
65 printf("stderr stream open: %s\n",
66 strerror(errno));
67 return 0;