<div dir="ltr">I think I've located my problem - it's a question of choosing the right pid. I'm debugging a multi-threaded application, and "ps" doesn't show the pid for each thread, whereas htop does. Choosing the pid of a specific thread causes strace to give me the statistics I'm looking for.<div>
<br></div><div>So it seems that if I run "strace -c" on a pid that is blocked in a system call, it doesn't print statistics at all. It's a little misleading; maybe it should print out statistics, and just show that 100% of the time it was in that call. Or maybe it can't detect the current call if strace was started after the call was made?</div>
<div><br></div><div>Either way, definitely operator error on my part.</div><div><br></div><div>- Bud</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 9, 2014 at 10:13 AM, Bud Millwood <span dir="ltr"><<a href="mailto:budm@weird-solutions.com" target="_blank">budm@weird-solutions.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dmitry, thanks for replying:<div><br></div><div>I'm not using the -l1 option. I see this behavior on both Ubuntu 12.10/x86-64 and CentOS 6.3/x86-64.</div>
<div><br></div><div>If I kill the target process, it always works correctly. The problem is if I use CTRL-C to detach from the target process. Eventually I managed to get it to produce the statistical output, as shown below. I used it for a few hours, then left the terminal open over night, and the next day it was not printing the output again. So it looks like this:</div>

<div><br></div><div>$ sudo strace -p 31457 -c<br></div><div><div>Process 31457 attached - interrupt to quit</div><div>^CProcess 31457 detached</div></div><div>$ sudo strace -p 31457 -c</div><div><div><div>Process 31457 attached - interrupt to quit</div>

<div>^CProcess 31457 detached</div></div></div><div>$ sudo strace -c -p 31457  <-- NOTE CHANGING COMMAND LINE ARGS ORDER<br></div><div>Process 31457 attached - interrupt to quit<br></div><div><div>^CProcess 31457 detached</div>
<div class="">
<div>% time     seconds  usecs/call     calls    errors syscall</div><div>------ ----------- ----------- --------- --------- ----------------</div></div><div> 75.38    0.047831          66       730           poll</div><div>
 24.62    0.015622          20       793           sendto</div>
<div>  0.00    0.000000           0        39           ioctl</div><div>  0.00    0.000000           0        39           select</div><div>  0.00    0.000000           0       769           recvfrom</div><div>  0.00    0.000000           0       107        29 futex</div>
<div class="">
<div>------ ----------- ----------- --------- --------- ----------------</div></div><div>100.00    0.063453                  2477        29 total</div></div><div><br></div><div>After this it worked for a while *regardless* of the order of the command line arguments. And then after 24 hours, it doesn't work again at all, *regardless* of command line argument order. So I just can't reproduce it reliably.</div>

<div><br></div><div>- I thought it might be because there were no system calls in the target process - that the target was blocked in one call, such as "select", but that's not the case.</div><div>- I tried sending SIGINT and SIGTERM to the strace process from another terminal, both signals cause the process to simply exit the same as if I pressed CTRL-C, i.e. no data printed.</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div><div>- Bud</div><div><div><br></div></div><div><br></div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 8, 2014 at 11:11 PM, Dmitry V. Levin <span dir="ltr"><<a href="mailto:ldv@altlinux.org" target="_blank">ldv@altlinux.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<div><br>
On Wed, May 07, 2014 at 04:54:40PM +0200, Bud Millwood wrote:<br>
> Hi all, I'm not on this list but I'll keep an eye out for a response<br>
> to this message.<br>
><br>
> In the past I noticed that if I ran "strace -c" against a process, I<br>
> could press CTRL-C and strace would print out the statistics it had<br>
> collected so far, then exit. It now seems to just exit without<br>
> printing any of the statistics.<br>
<br>
</div>Strange, it works for me, both in simple and in -p mode.<br>
For example:<br>
<br>
$ strace -c cat & sleep 1 && kill -INT $!<br>
[1] 19981<br>
Process 19985 detached<br>
% time     seconds  usecs/call     calls    errors syscall<br>
------ ----------- ----------- --------- --------- ----------------<br>
$  27.65    0.000060           8         8           mmap<br>
 14.29    0.000031           8         4           mprotect<br>
 10.14    0.000022           6         4           fstat<br>
  7.83    0.000017           9         2           open<br>
  7.83    0.000017           4         4           brk<br>
  6.45    0.000014           7         2         1 read<br>
  5.53    0.000012          12         1         1 access<br>
  5.07    0.000011           6         2           fadvise64<br>
  4.61    0.000010           5         2           close<br>
  4.61    0.000010          10         1           munmap<br>
  3.69    0.000008           8         1           execve<br>
  2.30    0.000005           5         1           arch_prctl<br>
------ ----------- ----------- --------- --------- ----------------<br>
100.00    0.000217                    32         2 total<br>
[1]+  Done                    strace -c cat<br>
<br>
$ sleep 2 && sleep 2 & sleep 1; strace -cp $! & sleep 2 && kill -INT $!<br>
[1] 19986<br>
[2] 19989<br>
Process 19986 attached<br>
Process 19986 detached<br>
% time     seconds  usecs/call     calls    errors syscall<br>
------ ----------- ----------- --------- --------- ----------------<br>
$  80.77    0.000710         355         2         1 wait4<br>
 15.81    0.000139         139         1           clone<br>
  2.62    0.000023           4         6           rt_sigprocmask<br>
  <a href="tel:0.46%20%C2%A0%20%C2%A00.000004" value="+46460000004" target="_blank">0.46    0.000004</a>           2         2           rt_sigaction<br>
  <a href="tel:0.34%20%C2%A0%20%C2%A00.000003" value="+46340000003" target="_blank">0.34    0.000003</a>           3         1           rt_sigreturn<br>
------ ----------- ----------- --------- --------- ----------------<br>
100.00    0.000879                    12         1 total<br>
[2]+  Done                    strace -cp $!<br>
[1]-  Done                    sleep 2 && sleep 2<br>
<br>
You aren't using -I1 option, are you?<br>
<span><font color="#888888"><br>
<br>
--<br>
ldv<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>