Created
April 5, 2016 22:20
-
-
Save dpsmith/3abe1b6d018b39b629b80cb7c79425d0 to your computer and use it in GitHub Desktop.
Debug a daemon that forks(clone) using strace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| self=$0 | |
| pid=$1 | |
| while read line; do | |
| echo $line >> ${pid}.log | |
| if $(echo $line | grep -q -e '^clone'); then | |
| child=$(echo $line|awk '{ print $5 }') | |
| echo "Parent: $pid" > ${child}.log | |
| if [[ -n $child ]]; then | |
| echo "$pid spawned: $child" | |
| ( $self $child )& | |
| fi | |
| fi | |
| done < <(strace -s 16384 -p $pid 2>&1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment