1#!/bin/bash
2#
3# usage: sudo who.sh
4#
5# Requires root permissions to both query who has the device open,
6# and to read the mappings of likely root-owned processes
7#
8
9for i in `lsof -t /dev/dri/card0`; do
10	who=`readlink /proc/$i/exe`
11	count=`grep /dev/dri/card0 /proc/$i/maps | wc -l | cut -f1 -d\ `
12	echo "$who [$i]: $count"
13done
14