Fix regression introduced by "Properly handle real SIGTRAPs" change

Commit 3454e4b463e6c22c7ea8c5461ef5a077f4650a54
introduced a bug: sometimes, TRACECLONE/TRACE[V]FORK opts were not set.
The check (tcp->parent == NULL) in old code was meant to check
"if we are not a child created by auto-attach" - in this case,
options need to be set on the child; otherwise they are inherited
and do not need to be set.
I misunderstood the check and if tcp->parent is not NULL, I was
setting only ptrace_setoptions_for_all bits.
This change fixes the problem. Since the fixed logic makes it
unnecessary to keep two sets of options in separate variables,
I merge them back into one variable, ptrace_setoptions.

* defs.h: Merge ptrace_setoptions_followfork and ptrace_setoptions_for_all
  into one variable, ptrace_setoptions.
* strace.c: Likewise.
  (test_ptrace_setoptions_followfork): Use ptrace_setoptions variable.
  (test_ptrace_setoptions_for_all): Likewise.
  (main): Likewise.
* process.c (internal_fork): Likewise.
  (internal_exec): Likewise.
* strace.c (trace): Fix the bug where different options were set
  depending on "tcp->parent == NULL" condition. Add a comment
  which makes it more clear why this condition is checked.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/strace.c b/strace.c
index 3298795..93e6d29 100644
--- a/strace.c
+++ b/strace.c
@@ -84,8 +84,7 @@
 
 
 int debug = 0, followfork = 0;
-unsigned int ptrace_setoptions_followfork = 0;
-unsigned int ptrace_setoptions_for_all = 0;
+unsigned int ptrace_setoptions = 0;
 /* Which WSTOPSIG(status) value marks syscall traps? */
 static unsigned int syscall_trap_sig = SIGTRAP;
 int dtime = 0, xflag = 0, qflag = 0;
@@ -826,7 +825,7 @@
 		}
 	}
 	if (expected_grandchild && expected_grandchild == found_grandchild)
-		ptrace_setoptions_followfork |= test_options;
+		ptrace_setoptions |= test_options;
 	return 0;
 }
 
@@ -907,10 +906,10 @@
 
 	if (it_worked) {
 		syscall_trap_sig = (SIGTRAP | 0x80);
-		ptrace_setoptions_for_all = test_options;
+		ptrace_setoptions |= test_options;
 		if (debug)
-			fprintf(stderr, "ptrace_setoptions_for_all = %#x\n",
-				ptrace_setoptions_for_all);
+			fprintf(stderr, "ptrace_setoptions = %#x\n",
+				ptrace_setoptions);
 		return;
 	}
 
@@ -1136,11 +1135,11 @@
 			fprintf(stderr,
 				"Test for options supported by PTRACE_SETOPTIONS "
 				"failed, giving up using this feature.\n");
-			ptrace_setoptions_followfork = 0;
+			ptrace_setoptions = 0;
 		}
 		if (debug)
-			fprintf(stderr, "ptrace_setoptions_followfork = %#x\n",
-				ptrace_setoptions_followfork);
+			fprintf(stderr, "ptrace_setoptions = %#x\n",
+				ptrace_setoptions);
 	}
 	test_ptrace_setoptions_for_all();
 #endif
@@ -2679,16 +2678,16 @@
 				}
 			}
 #ifdef LINUX
-			int options = ptrace_setoptions_for_all;
-			if (followfork && (tcp->parent == NULL))
-				options |= ptrace_setoptions_followfork;
-			if (options) {
-				if (debug)
-					fprintf(stderr, "setting opts %x on pid %d\n", options, tcp->pid);
-				if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, options) < 0) {
-					if (errno != ESRCH) {
-						/* Should never happen, really */
-						perror_msg_and_die("PTRACE_SETOPTIONS");
+			/* If options were not set for this tracee yet */
+			if (tcp->parent == NULL) {
+				if (ptrace_setoptions) {
+					if (debug)
+						fprintf(stderr, "setting opts %x on pid %d\n", ptrace_setoptions, tcp->pid);
+					if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {
+						if (errno != ESRCH) {
+							/* Should never happen, really */
+							perror_msg_and_die("PTRACE_SETOPTIONS");
+						}
 					}
 				}
 			}