From: Wichert Akkerman Date: Fri, 26 Nov 1999 13:11:29 +0000 (+0000) Subject: Add pollhack X-Git-Tag: v4.5.18~1159 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9dbf15466e9c178ac4090eba2c1232e2fe0706f9;p=strace Add pollhack --- diff --git a/ChangeLog b/ChangeLog index c6483c5c..bd679dbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ Fri Nov 26 10:51:55 CET 1999 Wichert Akkerman + allow net.c to compile on systems without AF_INET6 + Only use long_to_sigset on Linux systems + UnixWare treats sigmask_t and sigmask_t* as the same thing + + Add pollhack Fri Nov 26 01:28:09 CET 1999 Wichert Akkerman diff --git a/README-svr4 b/README-svr4 index 82febf77..8f66a7fd 100644 --- a/README-svr4 +++ b/README-svr4 @@ -16,5 +16,14 @@ on UnixWare 2.1 you need to add the following to config.h yourself: #define UNIXWARE 2 #define HAVE_POLLABLE_PROCFS 1 +On UnixWare using the -f option to follow forked children sometimes shows +many "unfinished" system calls as strace bounces between each runnable child. +A crude workaround for this is available by adding + + #define POLL_HACK 1 + +to the config.h file. This forces strace to check whether the last process +has finished a system call before polling other processes for events. + Wichert Akkerman diff --git a/strace.c b/strace.c index 45390b4d..f40f5d63 100644 --- a/strace.c +++ b/strace.c @@ -1243,6 +1243,9 @@ choose_pfd() static int trace() { +#ifdef POLL_HACK + struct tcb *in_syscall; +#endif struct tcb *tcp; int pfd; int what; @@ -1274,6 +1277,28 @@ trace() #endif /* !HAVE_POLLABLE_PROCFS */ default: #ifdef HAVE_POLLABLE_PROCFS +#ifdef POLL_HACK + /* On some systems (e.g. UnixWare) we get too much ugly + "unfinished..." stuff when multiple proceses are in + syscalls. Here's a nasty hack */ + + if (in_syscall) { + struct pollfd pv; + tcp = in_syscall; + in_syscall = NULL; + pv.fd = tcp->pfd; + pv.events = POLLWANT; + if ((what = poll (&pv, 1, 1)) < 0) { + if (interrupted) + return 0; + continue; + } + else if (what == 1 && pv.revents & POLLWANT) { + goto FOUND; + } + } +#endif + if (poll(pollv, nprocs, INFTIM) < 0) { if (interrupted) return 0; @@ -1297,6 +1322,7 @@ trace() fprintf(stderr, "unknown pfd: %u\n", pfd); exit(1); } + FOUND: /* Get the status of the process. */ if (!interrupted) { ioctl_result = IOCTL_WSTOP (tcp); @@ -1358,6 +1384,9 @@ trace() } break; case PR_SYSENTRY: +#ifdef POLL_HACK + in_syscall = tcp; +#endif case PR_SYSEXIT: if (trace_syscall(tcp) < 0) { fprintf(stderr, "syscall trouble\n");