b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/lib/commands/toolcontext.c |
| 2 | +++ b/lib/commands/toolcontext.c |
| 3 | @@ -1673,7 +1673,7 @@ struct cmd_context *create_toolcontext(u |
| 4 | /* FIXME Make this configurable? */ |
| 5 | reset_lvm_errno(1); |
| 6 | |
| 7 | -#ifndef VALGRIND_POOL |
| 8 | +#if defined(__GLIBC__) && !defined(VALGRIND_POOL) |
| 9 | /* Set in/out stream buffering before glibc */ |
| 10 | if (set_buffering |
| 11 | #ifdef SYS_gettid |
| 12 | @@ -2053,7 +2053,7 @@ void destroy_toolcontext(struct cmd_cont |
| 13 | dm_hash_destroy(cmd->cft_def_hash); |
| 14 | |
| 15 | dm_device_list_destroy(&cmd->cache_dm_devs); |
| 16 | -#ifndef VALGRIND_POOL |
| 17 | +#if defined(__GLIBC__) && !defined(VALGRIND_POOL) |
| 18 | if (cmd->linebuffer) { |
| 19 | /* Reset stream buffering to defaults */ |
| 20 | if (is_valid_fd(STDIN_FILENO) && |
| 21 | --- a/tools/lvmcmdline.c |
| 22 | +++ b/tools/lvmcmdline.c |
| 23 | @@ -3398,6 +3398,7 @@ int lvm_split(char *str, int *argc, char |
| 24 | /* Make sure we have always valid filedescriptors 0,1,2 */ |
| 25 | static int _check_standard_fds(void) |
| 26 | { |
| 27 | +#ifdef __GLIBC__ |
| 28 | int err = is_valid_fd(STDERR_FILENO); |
| 29 | |
| 30 | if (!is_valid_fd(STDIN_FILENO) && |
| 31 | @@ -3424,6 +3425,12 @@ static int _check_standard_fds(void) |
| 32 | strerror(errno)); |
| 33 | return 0; |
| 34 | } |
| 35 | +#else |
| 36 | + if (!is_valid_fd(STDERR_FILENO) || |
| 37 | + !is_valid_fd(STDOUT_FILENO) || |
| 38 | + !is_valid_fd(STDIN_FILENO)) |
| 39 | + return 0; |
| 40 | +#endif |
| 41 | |
| 42 | return 1; |
| 43 | } |