Thursday, 6 May 2021

Mysteries of strace

From this nice puzzle

 To figure it out, you can use the -T flag to strace which tells us how long each system call takes. The number in angle brackets (<......>) at the end of each line is how long that system call took, in seconds. Here's what that looks like:

 $ strace -tt -T -f  -p $(pgrep python) 
15:56:15.517327 accept4(3, {sa_family=AF_INET, sin_port=htons(48564), sin_addr=inet_addr("")}, [16], SOCK_CLOEXEC) = 4 <1.889267> 
15:56:17.407185 getsockname(4, {sa_family=AF_INET, sin_port=htons(8000), sin_addr=inet_addr("")}, [128->16]) = 0 <0.000018>

No comments:

Post a Comment