0001-Shellscript-stops-before-completing.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 1078af97a5ac5c3091c8e601b836cd69a7aab7fc Mon Sep 17 00:00:00 2001
  2. From: Stefano Babic <sbabic@denx.de>
  3. Date: Tue, 16 Jun 2020 10:29:55 +0200
  4. Subject: [PATCH] Shellscript stops before completing
  5. Commit 8fb94d7 reworks the way shell script are called, redirecting
  6. stdout and stderr to SWUpdate. A shell script runs then in a child
  7. process. Under some circumstances, SWUpdate closes the forked process
  8. before the child process completes.
  9. Be sure that the child process has terminated before to go on.
  10. Signed-off-by: Stefano Babic <sbabic@denx.de>
  11. Reported-by: Piotr Piwko <piotr.piwko@gmail.com>
  12. Tested-by: Piotr Piwko <piotr.piwko@gmail.com>
  13. ---
  14. core/pctl.c | 4 ++--
  15. 1 file changed, 2 insertions(+), 2 deletions(-)
  16. diff --git a/core/pctl.c b/core/pctl.c
  17. index 8b1c667..01ad540 100644
  18. --- a/core/pctl.c
  19. +++ b/core/pctl.c
  20. @@ -263,6 +263,7 @@ int run_system_cmd(const char *cmd)
  21. }
  22. } else {
  23. int fds[2];
  24. + pid_t w;
  25. close(stdoutpipe[PIPE_WRITE]);
  26. close(stderrpipe[PIPE_WRITE]);
  27. @@ -276,7 +277,6 @@ int run_system_cmd(const char *cmd)
  28. * and from stderr (of the child process) as ERROR
  29. */
  30. do {
  31. - pid_t w;
  32. int n1 = 0;
  33. struct timeval tv;
  34. fd_set readfds;
  35. @@ -373,7 +373,7 @@ int run_system_cmd(const char *cmd)
  36. }
  37. }
  38. } while (ret > 0 && n1 > 0);
  39. - } while (!WIFEXITED(wstatus));
  40. + } while (w != process_id);
  41. close(stdoutpipe[PIPE_READ]);
  42. close(stderrpipe[PIPE_READ]);
  43. --
  44. 2.25.1