Which process is occupying a certain pseudo terminal pts/X?
If you have fuser installed and have the permission to use sudo:
for i in $(sudo fuser /dev/pts/0); do
ps -o pid= -o command= -p $i
done
eg:
24622 /usr/bin/python /usr/bin/terminator
24633 ksh93 -o vi