Skip to content

Instantly share code, notes, and snippets.

@akash0x53
Last active August 29, 2015 14:11
Show Gist options
  • Save akash0x53/23f1218f163c9d2c4280 to your computer and use it in GitHub Desktop.
Save akash0x53/23f1218f163c9d2c4280 to your computer and use it in GitHub Desktop.
check processes for futex_wait
TRUE=0
FALSE=1
held_futex(){
tot=`ps -eo "%p %u %a"|awk '{ print ($2=="user") ? $0: ""}'|grep -c -i '[p]rocess'`
i=0
for pid in `ps -eo "%p %u %a"|awk '{ print ($2=="user") ? $0: ""}'|grep -i '[p]rocess'|awk '{ print $1 }'`
do
cnt=`cat /proc/${pid}/wchan|grep -c -i 'futex_wait_'`
if [ $cnt -gt 0 ];then
i=$((i+=1))
fi
done
[ $i -eq $tot ] && return $TRUE || return $FALSE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment