Output format fixes, improving the situation after recent
change which added better handling of processes suddenly
disappearing. Now we often do not finish last line
before exiting in those cases.
The only change affecting something other than output
is change in umovestr where we were calling
abort() on ptrace error.

* strace.c (trace): If trace_syscall() failed with ESRCH,
finish current output line with " <unfinished ...>".
(mp_ioctl): While we are at it, fix gross style mismatch
in this function definition. No code chages.
* syscall.c (trace_syscall): If decode fails on syscall exit,
finish current output line with "= ? <unavailable>".
* util.c (umoven): Do not complain if error is ESRCH.
(umovestr): Do not complain and do not abort() if error is ESRCH.
* defs.h: Remove unused tcp parameter from printtrailer().
* process.c: Adjust printtrailer() calls accordingly.
* strace.c: Adjust printtrailer() calls accordingly.
* syscall.c: Adjust printtrailer() calls accordingly.
diff --git a/strace.c b/strace.c
index 5c483fe..ba23b21 100644
--- a/strace.c
+++ b/strace.c
@@ -1593,7 +1593,7 @@
 	}
 	else
 		catch_sigstop = 1;
-	if (catch_sigstop)
+	if (catch_sigstop) {
 		for (;;) {
 #ifdef __WALL
 			if (wait4(tcp->pid, &status, __WALL, NULL) < 0) {
@@ -1637,6 +1637,7 @@
 			if (error < 0)
 				break;
 		}
+	}
 #endif /* LINUX */
 
 #if defined(SUNOS4)
@@ -1703,8 +1704,8 @@
 				"cleanup: looking at pid %u\n", tcp->pid);
 		if (tcp_last &&
 		    (!outfname || followfork < 2 || tcp_last == tcp)) {
-			tprintf(" <unfinished ...>\n");
-			tcp_last = NULL;
+			tprintf(" <unfinished ...>");
+			printtrailer();
 		}
 		if (tcp->flags & TCB_ATTACHED)
 			detach(tcp, 0);
@@ -2169,13 +2170,13 @@
 				printleader(tcp);
 				tprintf("--- %s (%s) ---",
 					signame(what), strsignal(what));
-				printtrailer(tcp);
+				printtrailer();
 #ifdef PR_INFO
 				if (tcp->status.PR_INFO.si_signo == what) {
 					printleader(tcp);
 					tprintf("    siginfo=");
 					printsiginfo(&tcp->status.PR_INFO, 1);
-					printtrailer(tcp);
+					printtrailer();
 				}
 #endif
 			}
@@ -2184,7 +2185,7 @@
 			if (!cflag && (qual_flags[what] & QUAL_FAULT)) {
 				printleader(tcp);
 				tprintf("=== FAULT %d ===", what);
-				printtrailer(tcp);
+				printtrailer();
 			}
 			break;
 #ifdef FREEBSD
@@ -2419,7 +2420,7 @@
 					WCOREDUMP(status) ? "(core dumped) " :
 #endif
 					"");
-				printtrailer(tcp);
+				printtrailer();
 			}
 #ifdef TCB_GROUP_EXITING
 			handle_group_exit(tcp, -1);
@@ -2608,7 +2609,7 @@
 				tprintf("--- %s (%s) @ %lx (%lx) ---",
 					signame(WSTOPSIG(status)),
 					strsignal(WSTOPSIG(status)), pc, addr);
-				printtrailer(tcp);
+				printtrailer();
 			}
 			if (((tcp->flags & TCB_ATTACHED) ||
 			     tcp->nclone_threads > 0) &&
@@ -2631,9 +2632,24 @@
 		if (interrupted)
 			return 0;
 		if (trace_syscall(tcp) < 0 && !tcp->ptrace_errno) {
-			if (tcp->flags & TCB_ATTACHED)
+			/* ptrace() failed in trace_syscall() with ESRCH.
+			 * Likely a result of process disappearing mid-flight.
+			 * Observed case: exit_group() terminating
+			 * all processes in thread group. In this case, threads
+			 * "disappear" in an unpredictable moment without any
+			 * notification to strace via wait().
+			 */
+			if (tcp->flags & TCB_ATTACHED) {
+				if (tcp_last) {
+					/* Do we have dangling line "syscall(param, param"?
+					 * Finish the line then. We cannot
+					 */
+					tcp_last->flags |= TCB_REPRINT;
+					tprintf(" <unfinished ...>");
+					printtrailer();
+				}
 				detach(tcp, 0);
-			else {
+			} else {
 				ptrace(PTRACE_KILL,
 					tcp->pid, (char *) 1, SIGTERM);
 				droptcb(tcp);
@@ -2768,8 +2784,7 @@
 }
 
 void
-printtrailer(tcp)
-struct tcb *tcp;
+printtrailer(void)
 {
 	tprintf("\n");
 	tcp_last = NULL;
@@ -2777,8 +2792,9 @@
 
 #ifdef HAVE_MP_PROCFS
 
-int mp_ioctl (int fd, int cmd, void *arg, int size) {
-
+int
+mp_ioctl(int fd, int cmd, void *arg, int size)
+{
 	struct iovec iov[2];
 	int n = 1;
 
@@ -2790,7 +2806,7 @@
 		iov[1].iov_len = size;
 	}
 
-	return writev (fd, iov, n);
+	return writev(fd, iov, n);
 }
 
 #endif