The file-descriptors tag has no wiki summary.
15
votes
3answers
1k views
When would you use an additional file descriptor?
I know you can create a file descriptor and redirect output to it. e.g.
exec 3<> /tmp/foo # open fd 3.
echo a >&3 # write to it
exec 3>&- # close fd 3.
But you can do the same ...
6
votes
1answer
3k views
File descriptors & shell scripting
I am having a very hard time understanding how does one use file descriptors in shell scripts.
I know the basics such as
exec 5 > /tmp/foo
So fd 5 is attached to foo for writing.
exec 6 < ...
8
votes
1answer
207 views
Order of redirections
I don't quite understand how the computer reads this command.
cat file1 file2 1> file.txt 2>&1
If I understand, 2>&1 simply redirect Standard Error to Standard Output.
By that ...
5
votes
3answers
1k views
Understanding /dev and its subdirs and files
$ ls -l /dev/stdin /dev/fd/0
lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2
lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0
$ ls -l /dev/pts/2 ...
5
votes
4answers
1k views
How can same fd in different processes point to the same file?
Say I have process 1 and process 2. Both have a file descriptor corresponding to the integer 4.
In each process however the file descriptor 4 points to a totally different file in the Open File Table ...
5
votes
0answers
88 views
How can different file descriptors point to the same file in open file table? [duplicate]
Possible Duplicate:
How can same fd in different processes point to the same file?
I have a hard time grasping the two ideas of File Descriptor Table and Open File Table.
Open File Table ...
7
votes
2answers
897 views
What happens when I close() a file descriptor?
I am trying to get the whole picture with file descriptors. Say I have process1 which initially has these file descriptors:
_process1_
| |
| 0 stdin |
| 1 stdout |
| 2 stderr |
...
3
votes
1answer
156 views
Timestamp of socket in /proc/<pid>/fd
If I list /proc/<pid>/fd I see a number of entries for sockets. These entries have timestamps. At first I thought they were when the socket was created. But it doesn't always appear to be the ...
5
votes
2answers
1k views
Execute command in remote active terminal
Suppose you have a terminal emulator (T1) open with a PID of 6350.
From another terminal, type this command (C1):
echo "ls\n" > /proc/6350/fd/0
This writes ls and the new line in T1 but does ...
4
votes
2answers
456 views
file descriptor vs. file name
I was wondering what differences and relations are between file descriptors and file names. Are they all used to access files? If yes, in the same way?
For example, /dev/fd/0, /dev/stdin, and ...
1
vote
3answers
118 views
How to check which process is using a given file descriptor?
Somewhere in the middle of my application, the framework I'm using (ROOT) gives me the following error:
*** Break *** write on a pipe with no one to read it
SysError in ...
