FAQ Database Discussion Community


Interpreting STRACE output - pipes and forks

c,linux,pipe,fork,strace
I have the following code written in C, taken from http://beej.us/guide/bgipc/output/html/multipage/pipes.html: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { int pfds[2]; pipe(pfds); if (!fork()) { close(1); /* close normal stdout */ dup(pfds[1]); /* make stdout same as pfds[1] */ close(pfds[0]); /* we don't need this */ execlp("/bin/ls", "ls", NULL);...

How to interpret the strace output

c++,boost,strace
When I execute the following program on the my embedded Linux nothing happens: #include <boost/thread/thread.hpp> #include <boost/lockfree/spsc_queue.hpp> #include <iostream> #include <boost/atomic.hpp> void Test(void) { std::cout << "Hello World" << std::endl; } int main(int argc, char* argv[]) { std::cout << "init"; boost::thread producer_thread(Test); producer_thread.join(); std::cout << "end"; } # ./prog ->...

Why does open() fails every time with EAGAIN?

linux,apache2,strace
Why would a program like Apache fail to open a plain file? Running it under strace shows: open("access.log", O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, 0666) = 11 11 stands for either EAGAIN or EWOULDBLOCK Where: $ ls -l access.log -rw-rw-rw- 1 root root 2 Jun 9 17:52 access.log If I su as www-data I can...

strace 'open' calls in a library of an executable

linux,unix,execution,tracing,strace
I have a program with no source code. When I run it, I have a "Can't open file..." error in the logs. I called strace to trace the open calls on the kernel, in that way: strace -e trace=open,close,read,write,connect,accept your-command-here However, it seems there is none of the open calls...

How do I kill strace without killing the process being traced?

linux,strace
I am attempting to debug the startup of an application. I would like to use strace to get a trace of the system calls carried out by the application during its startup, but once the application has started I don't want the performance overhead of strace. If you run strace...

Function dup2(int oldfd, int newfd) fails in for() loop

file,strace
I tried this for fun to see if it works but eventually it does not. i = open("something", O_RDWR); for(i ; i<10 ; i++); { if(dup2(i, i+1 ) == -1 ) { printf("Dup failed\n"); exit(1); } } I have straced the executable and the output is this: open("something", O_RDWR) =...