The file-descriptors tag has no wiki summary.
3
votes
2answers
57 views
Cross-process dup on Linux
I'd like to dup a file descriptor running in an unrelated process on Linux. I know about sendmsg(2) and SCM_RIGHTS (e.g. ...
3
votes
3answers
129 views
Something's special about /dev/fd/3
I've been trying to learn about file descriptors. When I type "ls -l /dev/fd/" I get
lrwx------ 1 me users 64 May 2 16:02 0 -> /dev/pts/5
l-wx------ 1 me users 64 May 2 16:02 1 -> ...
1
vote
3answers
115 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 ...
2
votes
1answer
56 views
open() console for default file descriptors
I'm reading a shell program implementation in C ( the xv6 shell from MIT's 6.828 Operating System Engineering course ).
The main() function for this shell starts with the following code:
//Assumes ...
1
vote
2answers
109 views
Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1
Just looking for the difference between
2>&-
2>/dev/null
|&
&>/dev/null
>/dev/null 2>&1
and their portability with non-Bourne shells like tcsh, mksh, etc.
0
votes
1answer
65 views
Understand Fd`s and nodejs
I'm having a bit of a confused time understanding what a file descriptor is and if I even need one! I am trying to spawn a process in nodejs and have its out put be written directly to an out put ...
2
votes
1answer
52 views
Why is it possible to refer to a closed stderr under bash?
I'd like to know why bash doesn't display an error message when we refer to a closed stderr. When it comes to other file descriptors, they have to be opened if we want to, for example, duplicate them. ...
8
votes
3answers
238 views
Practical use for moving file descriptors
According to the bash man page:
The redirection operator
[n]<&digit-
moves the file descriptor digit to file descriptor n, or the standard input
(file descriptor 0) if n is ...
2
votes
1answer
93 views
Significance of arrows symbols in duplicating/closing file descriptors under bash
I'm reading a book about Linux command line where author doesn't seem to follow the conventions in bash manual regarding arrows symbols used in redirection operations. Namely, he always uses left ...
1
vote
2answers
184 views
What sets a child's STDERR, STDOUT, and STDIN?
If a program runs fork() what sets standard streams STDOUT, STDIN and STDERR?
0
votes
2answers
107 views
Why doesn't Bash accept `&>&3`, i.e. redirecting stdout and stderr to file descriptor 3?
Given the preamble, foobar function and invocations of it:
exec 3>/dev/null
function foobar { echo foo; echo bar >&2; }
foobar >/dev/null
foobar 2>/dev/null
foobar ...
2
votes
1answer
54 views
How is the inherited file descritor vulnerability dealt with in Unices?
Ulrich Drepper describes a vulnerability in programs that have open file descriptors then they fork() and execve() without lots of very careful locking in place. He also talks about new kernel ...
1
vote
2answers
133 views
Where to place a Bash shell redirection for a command? [duplicate]
Possible Duplicate:
Order of redirections
Apart from the standalone exec >&2 to redirect the current shell's input and output are there any behavioral differences in the following ...
3
votes
1answer
154 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
1answer
76 views
Max Open Files, clarification needed
On my machine,
ulimit -n returns 2560
Given that -n returns
The maximum number of open file descriptors.
Does it mean that system won't allow more then 2560 open files to be out there at any ...
2
votes
1answer
263 views
Parameretrize file descriptor number to open a tcp socket in shell script
I'm tried to parameretrize in a variable the file descriptor number to open a tcp socket using exec command but it failed. Only work correctly when file descriptor number is a constant. In the next ...
2
votes
2answers
638 views
What are the dangers of setting a high limit to max File Descriptors per process?
I'm working on an old legacy application, and I commonly come across certain settings that no one around cam explain.
Apparently at some point, some processes in the application were hitting the max ...
5
votes
1answer
490 views
What is the file descriptor 3 assigned by default?
$ ls -og /proc/self /proc/self/fd
lrwxrwxrwx 1 64 Jun 18 11:12 /proc/self -> 32157
/proc/self/fd:
total 0
lrwx------ 1 64 Jun 22 2012 0 -> /dev/tty1
lrwx------ 1 64 Jun 22 2012 1 -> ...
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 ...
2
votes
1answer
156 views
Why doesnt ctrl+d work with this?
I wanted a simple way to process text in my clipboard without having to create a file. I tried using the following line:
awk '{print $1}' <(cat)
but I couldn't send cat the EOF character using ...
8
votes
1answer
206 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 ...
11
votes
2answers
508 views
Portability of “> /dev/stdout”
Occasionally I need to specify a "path-equivalent" of one of the standard IO streams (stdin, stdout, stderr). Since 99% of the time I work with Linux, I just prepend /dev/ to get /dev/stdin, etc., ...
5
votes
1answer
254 views
Why does reading from two connected pty's cause an infinite loop?
I want to fake a gsm modem for testing a program. I want the program to send AT-codes to me and that I can answer it back, kind of a VirtualSerialPort. But for some reason the data written from the ...
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 ...
7
votes
2answers
893 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 |
...
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 ...
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 ...
4
votes
2answers
455 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
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 ...
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 < ...
4
votes
2answers
851 views
What is the referent of a file descriptor?
My understanding is that a file descriptor is an integer which is a key in the kernel's per-process mapping to objects such as open()ed files, pipes, sockets, etc.
Is there a proper, short, and ...
5
votes
2answers
896 views
What's the purpose of the first argument to select system call?
From man select
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
nfds is the highest-numbered file descriptor in any of the three ...
2
votes
2answers
346 views
stop pipe() opening stdin
I've currently got code that forks two processes. The first reads a http streaming radio and pushes the data down a pipe (opened with pipe() ) for the second process to read, decode and output to the ...
4
votes
2answers
386 views
How does file descriptor re-assigment work?
In a way this question is a extension of another question.
In bash you can do pretty neat stuff with file descriptors. Like
{ command > /dev/null } 2>&1 | grep filter;
to grep on stderr ...

