1
0

patch-copy_xfs_copy_c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. --- xfsprogs-3.1.4.orig/copy/xfs_copy.c 2010-01-29 20:46:13.000000000 +0100
  2. +++ xfsprogs-3.1.4/copy/xfs_copy.c 2011-01-22 20:44:49.478658642 +0100
  3. @@ -240,6 +240,10 @@ handler(int sig)
  4. {
  5. pid_t pid = getpid();
  6. int status, i;
  7. + struct sigaction action;
  8. +
  9. + action.sa_handler = handler;
  10. + action.sa_flags = 0;
  11. pid = wait(&status);
  12. @@ -272,7 +276,7 @@ handler(int sig)
  13. pthread_exit(NULL);
  14. }
  15. - signal(SIGCHLD, handler);
  16. + sigaction(SIGCHLD, &action, NULL);
  17. return;
  18. } else {
  19. /* it just croaked it bigtime, log it */
  20. @@ -294,7 +298,7 @@ handler(int sig)
  21. do_warn(_("%s: Unknown child died (should never happen!)\n"), progname);
  22. die_perror();
  23. pthread_exit(NULL);
  24. - signal(SIGCHLD, handler);
  25. + sigaction(SIGCHLD, &action, NULL);
  26. }
  27. void
  28. @@ -467,6 +471,11 @@ void
  29. write_wbuf(void)
  30. {
  31. int i;
  32. + sigset_t unblock, initial;
  33. +
  34. + sigemptyset(&unblock);
  35. + sigaddset(&unblock, SIGCHLD);
  36. +
  37. /* verify target threads */
  38. for (i = 0; i < num_targets; i++)
  39. @@ -478,9 +487,9 @@ write_wbuf(void)
  40. if (target[i].state != INACTIVE)
  41. pthread_mutex_unlock(&targ[i].wait); /* wake up */
  42. - sigrelse(SIGCHLD);
  43. + sigprocmask(SIG_UNBLOCK, &unblock, &initial);
  44. pthread_mutex_lock(&mainwait);
  45. - sighold(SIGCHLD);
  46. + sigprocmask(SIG_SETMASK, &initial, NULL);
  47. }
  48. @@ -521,6 +530,12 @@ main(int argc, char **argv)
  49. libxfs_init_t xargs;
  50. thread_args *tcarg;
  51. struct stat64 statbuf;
  52. + struct sigaction saction;
  53. + sigset_t sigblock, initial;
  54. +
  55. + saction.sa_handler = handler;
  56. + saction.sa_flags = 0;
  57. +
  58. progname = basename(argv[0]);
  59. @@ -846,8 +861,11 @@ main(int argc, char **argv)
  60. /* set up sigchild signal handler */
  61. - signal(SIGCHLD, handler);
  62. - sighold(SIGCHLD);
  63. + sigaction(SIGCHLD, &saction, NULL);
  64. + sigemptyset(&sigblock);
  65. + sigaddset(&sigblock, SIGCHLD);
  66. + sigprocmask(SIG_BLOCK, &sigblock, &initial);
  67. +
  68. /* make children */