Valgrind fails to create log files - "Permission denied"

103 views Asked by At

I am running a Linux application consisting of several executables. They are structured like this:

base_app is run under superuser and creates su_app and non_su_app via fork

non_su_app needs to be run with normal user privileges, not superuser. For that I call setegid and setepid after the fork call

Now I want to do some memory profiling on these apps with valgrind and collect the profiling logs separately for each process. I run

sudo valgrind --tool=memcheck --trace-children=yes --leak-check=full --show-leak-kinds=all --log-file=/tmp/log_files/valgrind-%p /path/to/base_app 

which works fine for base_app and su_app but when the code tries to launch non_su_app I get

valgrind: Cannot create log file '/tmp/log_files/valgrind-15056': Permission denied

over and over. And the app fails to start completely.

I tried changing the permissions of the log folder to 777 or doing something like

valgrind --tool=memcheck --trace-children=yes --leak-check=full --show-leak-kinds=all --log-file=/tmp/log_files/valgrind-%p sudo /path/to/base_app 

to no avail. Are there any ways to properly collect to logs from these processes?

0

There are 0 answers