Move prctl call in TestChangeProcessGroup to the child
authorPavel Labath <labath@google.com>
Thu, 28 May 2015 10:28:34 +0000 (10:28 +0000)
committerPavel Labath <labath@google.com>
Thu, 28 May 2015 10:28:34 +0000 (10:28 +0000)
I was hoping the enable-tracing flag will be inherited from the parent. It is not.

llvm-svn: 238408

lldb/test/functionalities/process_group/main.c

index 5de63db..c730c62 100644 (file)
@@ -10,19 +10,6 @@ volatile int release_child_flag = 0;
 
 int main(int argc, char const *argv[])
 {
-#if defined(__linux__)
-    // Immediately enable any ptracer so that we can allow the stub attach
-    // operation to succeed.  Some Linux kernels are locked down so that
-    // only an ancestor process can be a ptracer of a process.  This disables that
-    // restriction.  Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
-    // For now we execute on best effort basis.  If this fails for
-    // some reason, so be it.
-    const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
-    (void) prctl_result;
-#endif
-#endif
-
     pid_t child = fork();
     if (child == -1)
     {
@@ -74,6 +61,19 @@ int main(int argc, char const *argv[])
     }
     else
     { // child
+#if defined(__linux__)
+        // Immediately enable any ptracer so that we can allow the stub attach
+        // operation to succeed.  Some Linux kernels are locked down so that
+        // only an ancestor process can be a ptracer of a process.  This disables that
+        // restriction.  Without it, attach-related stub tests will fail.
+#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
+        // For now we execute on best effort basis.  If this fails for
+        // some reason, so be it.
+        const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
+        (void) prctl_result;
+#endif
+#endif
+
         while (! release_child_flag) // Wait for debugger to attach
             sleep(1);