Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've created a little function for strace'ing a set of the current user's processes by name:

function pstrace() {
    local pattern="$1";
    shift;
    prefixDashP $(pgrep -U $(whoami) $pattern) | xargs strace -o /dev/stdout $@;
}

function prefixDashP() {
    local new_args=();
    for arg; do
        new_args+=( '-p' );
        new_args+=( "$arg" );
    done;
    for arg in "${new_args[@]}"; do
        echo "$arg";
    done;
}

# Usage:  pstrace pattern1 pattern2 ...

The trouble is, if I accidentally specify too broad of a pattern, it tries to monitor processes that it shouldn't monitor, and so my system freezes.

Is there a list of processes that I can always exclude?

share|improve this question
add comment

1 Answer

You must not trace any process that's involved in processing the output of strace. This means, at least, the terminal emulator in which you're running strace. I wouldn't expect your whole system to be frozen, only slowed down; uless you're running strace as root and tracing your X server, you should be able to switch to a different terminal and kill the strace process.

It would be less risky and probably more convenient to send the strace output to a file. Start less after starting strace, and kill it if you've accidentally traced the terminal emulator.

If you feel like tracing a lot of processes, you may be using the wrong tool. A system-wide audit system, such as Linux's (see examples and pointers here or here), may be more appropriate.

share|improve this answer
    
Well spotted! Looks more like a livelock than a deadlock, so the system will probably be unstable (at least). –  Stéphane Gimenez Jul 31 '11 at 23:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.