Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
1answer
68 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 ...
2
votes
2answers
173 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 ...
6
votes
1answer
526 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
154 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 ...
3
votes
1answer
679 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 ...
3
votes
2answers
4k 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
3k 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 -> ...
7
votes
2answers
5k 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
314 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 ...
10
votes
2answers
488 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 ...
16
votes
2answers
1k 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
480 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 ...
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 ...
12
votes
2answers
3k 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
102 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 ...
27
votes
4answers
6k 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
2answers
1k 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 ...
13
votes
3answers
4k 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
1answer
8k 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
1k 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 ...
8
votes
2answers
2k 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
413 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
519 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 ...