Question

"strace wget grooveshark.com" stops with strange socket calls with wrong string length and I have to Ctrl+C to terminate.

write(2, "Connecting to grooveshark.com (g"..., 67Connecting to grooveshark.com (grooveshark.com)|8.20.213.76|:80... ) = 67
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("8.20.213.76")}, 16) = 0
write(2, "connected.\n", 11connected.
)            = 11
select(4, NULL, [3], NULL, {900, 0})    = 1 (out [3], left {899, 999993})
write(3, "GET / HTTP/1.1\r\nUser-Agent: Wget"..., 115) = 115
write(2, "HTTP request sent, awaiting resp"..., 40HTTP request sent, awaiting response... ) = 40 [[ Check this line ]]
select(4, [3], NULL, NULL, {900, 0} ^C 

write(2, "HTTP request sent, awaiting resp"..., 40HTTP request sent, awaiting response... ) = 40

should be

write(2, "HTTP request sent, awaiting response...", 40 ) = 40

but strace wget google.com gives

write(3, "GET / HTTP/1.1\r\nUser-Agent: Wget"..., 116) = 116
write(2, "HTTP request sent, awaiting resp"..., 40) = 40
select(4, [3], NULL, NULL, {900, 0})    = 1 (in [3], left {899, 932611})

and properly terminates.

Thanks

Was it helpful?

Solution

You are seeing the output of wget mixed with the output of strace. Use the -o option of strace to store the trace in a file so that this won't happen.

write(2, "HTTP request sent, awaiting resp"..., 40HTTP request sent, awaiting response... ) = 40

This write call in wget prints the message to stderr, and before it returns, its output is seen in the terminal, between 40 and the closing parenthesis

OTHER TIPS

By default strace is outputting on stderr which is usually your terminal window. So the trace given by strace is mixed with the output of the traced program.

You could run strace -o /tmp/wget.tr wget http://grooveshark.com/ to get the trace in file /tmp/wget.tr (and you could run simultanously tail -f /tmp/wget.tr in another terminal to look inside).

I suggest to read carefully the output of man strace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top