fix-stdio-usage.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --- ./tools/lvmcmdline.c
  2. +++ ./tools/lvmcmdline.c
  3. @@ -1252,7 +1252,7 @@
  4. int err = is_valid_fd(STDERR_FILENO);
  5. if (!is_valid_fd(STDIN_FILENO) &&
  6. - !(stdin = fopen(_PATH_DEVNULL, "r"))) {
  7. + !freopen(_PATH_DEVNULL, "r", stdin)) {
  8. if (err)
  9. perror("stdin stream open");
  10. else
  11. @@ -1262,7 +1262,7 @@
  12. }
  13. if (!is_valid_fd(STDOUT_FILENO) &&
  14. - !(stdout = fopen(_PATH_DEVNULL, "w"))) {
  15. + !freopen(_PATH_DEVNULL, "w", stdout)) {
  16. if (err)
  17. perror("stdout stream open");
  18. /* else no stdout */
  19. @@ -1270,7 +1270,7 @@
  20. }
  21. if (!is_valid_fd(STDERR_FILENO) &&
  22. - !(stderr = fopen(_PATH_DEVNULL, "w"))) {
  23. + !freopen(_PATH_DEVNULL, "w", stderr)) {
  24. printf("stderr stream open: %s\n",
  25. strerror(errno));
  26. return 0;
  27. --- ./lib/commands/toolcontext.c.orig
  28. +++ ./lib/commands/toolcontext.c
  29. @@ -1860,7 +1860,7 @@
  30. /* FIXME Make this configurable? */
  31. reset_lvm_errno(1);
  32. -#ifndef VALGRIND_POOL
  33. +#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
  34. /* Set in/out stream buffering before glibc */
  35. if (set_buffering
  36. #ifdef SYS_gettid
  37. @@ -2254,7 +2254,7 @@
  38. if (cmd->libmem)
  39. dm_pool_destroy(cmd->libmem);
  40. -#ifndef VALGRIND_POOL
  41. +#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
  42. if (cmd->linebuffer) {
  43. /* Reset stream buffering to defaults */
  44. if (is_valid_fd(STDIN_FILENO) &&