The tag has no wiki summary.

learn more… | top users | synonyms

23
votes
4answers
4k 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 ...
9
votes
1answer
6k 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 < ...
10
votes
2answers
400 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
2answers
230 views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
12
votes
3answers
3k 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 ...
9
votes
4answers
3k 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 ...
7
votes
2answers
4k 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 ...
5
votes
1answer
2k views

How to circumvent “Too many open files” in debian

If I want to see all relevant log files of my apache2 server at once, I use tail -f /var/kunden/logs/*log /var/kunden/logs/*log /var/log/apache2/*log |grep -v robots|grep -v favicon But since those ...
6
votes
2answers
845 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 ...
5
votes
0answers
99 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 ...
2
votes
4answers
96 views

Can a running script identify the logging context?

Let us say I redirect the STDOUT, STDERR of a program to files. ./script.sh 1> output.log 2> error.log Can the running program find this out i.e. know the paths to these files?
11
votes
2answers
2k 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 | ...
4
votes
1answer
430 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 ...
2
votes
2answers
451 views

Close all file descriptors in bash

Is there a way to close all the open file descriptors, without having an explicit list of them beforehand?
4
votes
3answers
531 views

Please help explain this bash output redirection

This script was posted as answer to a Question. And I'm trying to work out what's going on. result=$( { { ssh host app-status >&3 3>&-; echo "$?" } | { until read ...
1
vote
3answers
836 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 ...