]> mj.ucw.cz Git - moe.git/commitdiff
Box: Use SIGSTOP to notify the parent that the child is ready to be traced
authorMartin Mares <mj@ucw.cz>
Sat, 28 Mar 2009 16:21:53 +0000 (17:21 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 28 Mar 2009 16:21:53 +0000 (17:21 +0100)
instead of SIGCHLD. This should be safer.

box/box.c

index da7dfc1b83ca4e3cfbb7c34d734037db2973e47a..f574f864dbd3fb0eb6909dd18eaecbcc38b6526c 100644 (file)
--- a/box/box.c
+++ b/box/box.c
@@ -944,6 +944,11 @@ boxkeeper(void)
                msg("= %ld\n", u.regs.eax);
              ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
            }
+         else if (sig == SIGSTOP)
+           {
+             msg(">> SIGSTOP\n");
+             ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
+           }
          else if (sig != SIGSTOP && sig != SIGXCPU && sig != SIGXFSZ)
            {
              msg(">> Signal %d\n", sig);
@@ -1007,8 +1012,7 @@ box_inside(int argc, char **argv)
       if (ptrace(PTRACE_TRACEME) < 0)
        die("ptrace(PTRACE_TRACEME): %m");
       /* Trick: Make sure that we are stopped until the boxkeeper wakes up. */
-      signal(SIGCHLD, SIG_IGN);
-      raise(SIGCHLD);
+      raise(SIGSTOP);
     }
   execve(args[0], args, env);
   die("execve(\"%s\"): %m", args[0]);