File: signal-rr-recording.sh

package info (click to toggle)
rr 5.9.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,944 kB
  • sloc: ansic: 66,398; cpp: 57,679; python: 4,627; asm: 1,331; sh: 576; xml: 411; makefile: 30
file content (22 lines) | stat: -rwxr-xr-x 554 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

signal=$1
if [[ "$signal" == "" ]]; then
    echo "Usage: $0 <signal>" >&2
    echo "Sends <signal> to all processes being recorded by rr" >&2
    exit 1
fi

function signal_descendants { pid=$1
    for child in `ps -o pid= --ppid $pid`; do
        echo Sending $signal to $child
        kill -s $signal $child
        signal_descendants $child
    done
}

for rr_pid in `pidof rr` ; do
    if cat /proc/$rr_pid/cmdline | tr '\0' '\n' | head -n2 | tail -n1 | grep -qz '\(^record$\)\|/'  ; then
        signal_descendants $rr_pid
    fi
done