0002-Shellscript-stops-before-completing.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From bd08e45d7b25f06da2fc6dc824146b471db5f1f4 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. Signed-off-by: Joris Offouga <offougajoris@gmail.com>
  14. ---
  15. core/pctl.c | 4 ++--
  16. 1 file changed, 2 insertions(+), 2 deletions(-)
  17. diff --git a/core/pctl.c b/core/pctl.c
  18. index 8b1c667..01ad540 100644
  19. --- a/core/pctl.c
  20. +++ b/core/pctl.c
  21. @@ -263,6 +263,7 @@ int run_system_cmd(const char *cmd)
  22. }
  23. } else {
  24. int fds[2];
  25. + pid_t w;
  26. close(stdoutpipe[PIPE_WRITE]);
  27. close(stderrpipe[PIPE_WRITE]);
  28. @@ -276,7 +277,6 @@ int run_system_cmd(const char *cmd)
  29. * and from stderr (of the child process) as ERROR
  30. */
  31. do {
  32. - pid_t w;
  33. int n1 = 0;
  34. struct timeval tv;
  35. fd_set readfds;
  36. @@ -373,7 +373,7 @@ int run_system_cmd(const char *cmd)
  37. }
  38. }
  39. } while (ret > 0 && n1 > 0);
  40. - } while (!WIFEXITED(wstatus));
  41. + } while (w != process_id);
  42. close(stdoutpipe[PIPE_READ]);
  43. close(stderrpipe[PIPE_READ]);
  44. --
  45. 2.25.1