patch-copy_xfs_copy_c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. $Id: update-patches 24 2008-08-31 14:56:13Z wbx $
  2. --- xfsprogs-3.0.0.orig/copy/xfs_copy.c 2009-02-04 23:29:25.000000000 +0100
  3. +++ xfsprogs-3.0.0/copy/xfs_copy.c 2009-03-27 11:40:33.000000000 +0100
  4. @@ -240,7 +240,10 @@ handler(int sig)
  5. {
  6. pid_t pid = getpid();
  7. int status, i;
  8. + struct sigaction action;
  9. + action.sa_handler = handler;
  10. + action.sa_flags = 0;
  11. pid = wait(&status);
  12. kids--;
  13. @@ -272,7 +275,7 @@ handler(int sig)
  14. pthread_exit(NULL);
  15. }
  16. - signal(SIGCHLD, handler);
  17. + sigaction(SIGCHLD, &action, NULL);
  18. return;
  19. } else {
  20. /* it just croaked it bigtime, log it */
  21. @@ -294,7 +297,7 @@ handler(int sig)
  22. do_warn(_("%s: Unknown child died (should never happen!)\n"), progname);
  23. die_perror();
  24. pthread_exit(NULL);
  25. - signal(SIGCHLD, handler);
  26. + sigaction(SIGCHLD, &action, NULL);
  27. }
  28. void
  29. @@ -467,6 +470,10 @@ void
  30. write_wbuf(void)
  31. {
  32. int i;
  33. + sigset_t unblock, initial;
  34. +
  35. + sigemptyset(&unblock);
  36. + sigaddset(&unblock, SIGCHLD);
  37. /* verify target threads */
  38. for (i = 0; i < num_targets; i++)
  39. @@ -478,9 +485,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 +528,11 @@ 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. progname = basename(argv[0]);
  58. @@ -846,8 +858,10 @@ main(int argc, char **argv)
  59. /* set up sigchild signal handler */
  60. - signal(SIGCHLD, handler);
  61. - sighold(SIGCHLD);
  62. + sigaction(SIGCHLD, &saction, NULL);
  63. + sigemptyset(&sigblock);
  64. + sigaddset(&sigblock, SIGCHLD);
  65. + sigprocmask(SIG_BLOCK, &sigblock, &initial);
  66. /* make children */