I created this script, which listens for characters received on a hardcoded pipe, and tries to eval
those characters. I call my script loop_executor.sh
This is all it contains:
!/bin/bash
while :
do
x=`cat /tmp/console_test`;
echo "received $x"
eval $x
done;
I execute my script with a double click.
I want to see what files this process has open:
> $ pgrep loop_executor.sh
1234
> $ ll /proc/1234/fd
dr-x------ 2 userX domain^users 0 Oct 20 17:57 ./
dr-xr-xr-x 9 userX domain^users 0 Oct 20 17:57 ../
lr-x------ 1 userX domain^users 64 Oct 20 17:57 0 -> /dev/null
l-wx------ 1 userX domain^users 64 Oct 20 17:57 1 -> /dev/null
l-wx------ 1 userX domain^users 64 Oct 20 17:57 2 -> /home/local/groupX/userX/.xsession-errors
lr-x------ 1 userX domain^users 64 Oct 20 17:58 255 -> /home/local/groupX/userX/Desktop/loop_executor.sh*
lr-x------ 1 userX domain^users 64 Oct 20 17:57 3 -> pipe:[225812]
FD 3 points to a "pipe". Well i know what file it uses, because I'm the one that hardcoded the file in the script, but I'd like to get this information (if possible) from another source (since my script is just a POC, and it could be a process whose code is not open to me).
What I understood, is that pipe:[225812]
doesn't point to the inode of my file.
ll -i /tmp/console_test
16519395 prw-r--r-- 1 userX domain^users 0 Oct 20 18:14 /tmp/console_test|
So my question is: If processess can open pipes, which are files on my system, can I determine which files those pipes "corresponded" to?
I'm using ubuntu 12.04 if that matters.
[EDIT]
Found the cat
process that was reading from my pipe. It has the same opened pipe as its parent process, so it doesn't make much of a difference here -> i still don't know just by looking at pipe:[225812]
what file -if any - that is.
. /tmp/console
instead? – chepner Oct 20 '14 at 16:32pipe:[225812]
- it's an anonymous pipe. likely you can reference it w/ the special link/dev/fd/3
– mikeserv Oct 20 '14 at 16:48