The tag has no usage guidance.

learn more… | top users | synonyms

0
votes
1answer
23 views

How to manipulate a file descriptor in another process? [duplicate]

Is there any way to manipulate (read, write, etc..) a file descriptor for any app which can be found in the path /proc/{pid}/fd? Especially for sockets. $ ll /proc/4229/fd total 0 lrwx------. 1 ...
1
vote
0answers
15 views

Redirect all output, including input prompts [duplicate]

I know that doing command &> /dev/null suppresses all output file descriptors. But I notice that it does not work for commands that request input from the user, most notably ssh: > ssh ...
4
votes
1answer
84 views

Executing commands in an elevated bash process by writing to the standard input of its parent script process

I have a simple bash script bash.sh that starts another bash instance using pkexec. #!/bin/bash bash -c 'pkexec bash' When executed this shows a prompt for the user to enter their password. The ...
3
votes
2answers
37 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with ...
0
votes
1answer
55 views

How “Max open files” soft and hard limit are set for specific process?

I used the cat /proc/<pid>/limits command to check the Max open file hard and soft limit, but I want to know how this value will be set and can it be increased or decreased? Is this value is ...
3
votes
1answer
45 views

mkfifo pipes, file descriptors and ImageMagick (convert)

I'm in trouble using named pipes (i.e. created with mkfifo) and file descriptors to redirect outputs and grab inputs to/from them within ImageMagick (convert). Basically, with the following bash code ...
2
votes
0answers
20 views

How unmounting closes file descriptors?

Checking currently open files on my /Volumes/UNTITLED gives me 2 entries: $ sudo lsof /Volumes/UNTITLED/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mds 62 root 8r DIR 1,6 ...
1
vote
1answer
40 views

How to handle broken link after file deletion.in /proc/<pid>/fd directory?

A process is creating huge number of log files and also deleting it. Many of those deleted files are having broken links in the /proc/pid/fd directory. Do these file handles need to be closed by ...
4
votes
1answer
68 views

File descriptors and redirect in bash

Can someone explain why this command works: gpg --enable-special-filenames --verify --batch \ <(curl -s https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.0.29.tar.bz2.sig) \ <(curl ...
2
votes
1answer
54 views

Two input pipes through file descriptor shuffling and /dev/fd

I want to pipe two programs into one. If my shell supports it, I can use Process substitution. For example, to list the common lines of two files in indifferent order, I can use comm -12 <(sort a) ...
1
vote
1answer
35 views

How to get file descriptor number of a output and how to redirect all of them at once

Lets take this command for example $ time ssh ec2 ls www apps real 0m0.554s user 0m0.004s sys 0m0.000s $ time ssh ec2 ls 1>/dev/null real 0m0.554s user 0m0.004s sys 0m0.000s ...
3
votes
1answer
49 views

Opening more than 10 file descriptors with ksh

The shell syntax for opening a file for writing and using its file descriptor is: exec 3>output.log With bash and zsh you also can write: exec 13>output.log Thus, later in your script you ...
11
votes
2answers
185 views

What is the difference between &6 and /dev/fd/6?

To read from file descriptor 6 I can use <&6 or </dev/fd/6 (aka /proc/self/fd/6). Usually both work equally well. However if that file descriptor happens to be a socket, strange things ...
0
votes
1answer
32 views

Problem about file descriptor

I am doing a project. But I found in the source code there are so many file descriptor left unclosed. The first glance of it, I thought this is not good. After I googled, someone says, if there are ...
5
votes
2answers
851 views

Running remote command with ssh getting “bash: /dev/fd/63: No such file or directory”

I have /root/test.sh on a remote server, which has the following content: #!/bin/bash date On the remote server, I get the following output: # ./test.sh Fri Dec 18 07:41:10 EST 2015 # bash ...
4
votes
5answers
414 views

File descriptors across exec

By default file descriptors remain open across the exec functions. The benefit is perhaps understandable for descriptors 0-2. But is there a practical use case for keeping other descriptors open? Are ...
3
votes
2answers
63 views

Do redirections operate on file descriptors or file handles?

From https://www.gnu.org/s/bash/manual/html_node/Redirections.html Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. ...
3
votes
1answer
70 views

Duplication of file descriptors in redirection

From https://www.gnu.org/software/bash/manual/html_node/Redirections.html Bash handles several filenames specially when they are used in redirections, as described in the following table: ...
3
votes
1answer
77 views

Need Explanation For Multiple Arguments And Input Redirection With Cat

Files along with their contents:- ~$cat a aaa aaa aaa ~$cat b bbb bbb bbb ~$cat c ccc ccc ccc Commands that I need explanation:- ~$cat 0< a aaa aaa aaa ~$cat 0< a b bbb bbb bbb ~$cat 0< a ...
11
votes
4answers
385 views

Program output redirection

When trying to redirect program output with the "some number greater than" syntax (eg foo 2> myfile), what are the possible numbers here and what do they represent? I believe 1 is /dev/stdout, 2 ...
1
vote
0answers
26 views

Etymology of “descriptor” in “file descriptor”

The choice of the word descriptor has always struct me as odd. "Index" or "id" seem like more obvious alternatives. Is there a known rationale for the choosing the word "descriptor"? I guess ...
4
votes
2answers
50 views

Tar is currently reading a 2GB file, and I deleted its only link. How do I stop it from running for an eternity?

Some more information: I was backing up a large directory with tar, only there were a couple of large files there that I didn't expect. This connection is over the network and very slow, so simply ...
1
vote
1answer
111 views

File descriptor to read kernel log messages?

I am using syslog to read kernel log messages with SYSLOG_ACTION_READ. I would like to know if it's possible to "obtain" a file descriptor to "something" that would send the kernel logs (like what ...
-1
votes
2answers
105 views

How do I Capture dd command output

I have a test script, which is used to estimate the filesize for a particular oracle export dumpfile. Content of the script is: mknod exp.pipe p dd if=exp.pipe of=/dev/null bs=1024 & exp ...
3
votes
4answers
132 views

How to link a log file to /dev/null and restore the space used automatically

I have a logfile which grows huge. The information that I can get from it is negligible. I want to link it to /dev/null. However, even if it is "deleted" (see below the output of lsof), it consumes ...
4
votes
2answers
164 views

SSH: Provide additional “pipe” fds in addition to stdin, stdout, stderr

When connecting to a host with SSH, usually three "pipes" are provided between host and guest, for stdin, stdout, and stderr. Is there a command-line option to create forwards for additional file ...
1
vote
3answers
169 views

in bash script; a process stdout as filename argument fails when you open it more than one time

Consider this bash script code: #!/bin/bash function bug_part() { cat $1 > sample.first cat $1 > sample.second #second time you open file $1, it contains no data } bug_part <(echo ...
0
votes
1answer
28 views

Special file descriptors

In shell scripting, are any file descriptors other than 0, 1 and 2 special in any way? The flock manpage has the following example code: ( flock -n 9 || exit 1 # ... commands executed ...
2
votes
1answer
262 views

Strace - Filedescriptor 3

I am not sure what the filedescriptor number 3 means here? Is this descriptor some kind of pointer to the connection made to the harddrive to get the file datlog.txt? I guess so because the subroutine ...
0
votes
0answers
42 views

writefile() to file descriptor produces output with alignment issue

The command that produces weird output: $ vim -ec 'call writefile(["line1","line2"],"/proc/self/fd/9") | qall!' 9>&1 1>/dev/null 2>&1 line1 line2 $ Same command ...
1
vote
1answer
356 views

How can a file descriptor be reclaimed and reused later?

In context of C and C++, is the close() system call the only way for kernel to reclaim the fd and reuse it later when calling open() in the same process lifetime? What about multi-threaded programs?
2
votes
0answers
186 views

Process exceeding max open files limit

I am counting current open files by a process pid by :- cmd1:- ls /proc/$pid/fd/* | wc -l and then I am calculating percentage by fetching Max open Files limits. cmd2:- $ cat /proc/$pid/limits ...
9
votes
1answer
242 views

OS X, bash: less works on open file descriptors, cat doesn't

In a bash script I'm working on (which has to run on Ubuntu and OS X), I need to redirect the output of hundreds of commands to a file. Rather than appending &>... to all of them, I simply do ...
0
votes
1answer
133 views

Who opened a file descriptor? (socket)

I am using strace to track a program. In this line: recvfrom(7, "\0\260R\0\0\1\364\6\215\r\257\330\210\341\0\270\240\0\260R\0\0\0\0\0\0\0\0\0\0\0\0"..., 3000, 0, {sa_family=AF_PACKET, proto=0x88e1, ...
2
votes
1answer
642 views

File descriptor limits in /etc/system vs /etc/sysctl.conf vs /etc/security/limits.conf on Solaris

Let me explain first what I understood. In Solaris 10, rlim_fd_max and rlim_fd_cur in /etc/system set the hard and soft limits at the system level. And /etc/security/limits.conf sets the limits for ...
4
votes
5answers
2k views

Testing if a file descriptor is valid

I'd like to make a bash script output additional information to file descriptors (FDs) greater than or equal to 3, when they are open. To test whether an FD is open, I devised the following trick: if ...
0
votes
1answer
45 views

FDs more than 2, more than (stdin/stdout/sterr)

I think this post is not off-topic.We had three traditional file descriptors in Unix contexts: 0 == STDIN 1 == STDOUT 2 == STDERR But in new articles, blogs, posts, answers, or so on, I read more ...
1
vote
2answers
937 views

How to display open file descriptors with thread id but not using lsof command

How to display open file descriptors with thread id but not using lsof. I know a similar question exists but the answer doesnt include thread details.
2
votes
1answer
207 views

understanding “dpkg --status-fd n”

From man dpkg (1.16.16 (i386) on a Debian (7) based Linux Distro): --status-fd n Send machine-readable package status and progress information to file descriptor n I read this ...
1
vote
1answer
33 views

Propose additional file descriptor “stdmeta” [closed]

I know that one can define additional file descriptors for ad-hoc use. However, I see real use for a "stdmeta" file descriptor that would be supported by common CLI tools. This file descriptor would ...
1
vote
2answers
430 views

why nginx holds file descriptions of logs?

on Red Hat Enterprise Linux Server release 6.6 (Santiago) nginx version: nginx/1.0.15 I use common nginx logrotate config, logrotate works fine and nginx creates new log file like access.log or ...
2
votes
4answers
426 views

What is an open file description?

When you fork a process, the child inherits its parent's file descriptors. I understand that when this happens, the child receives a copy of the parent's file descriptor table with the pointers in ...
0
votes
1answer
137 views

Accessing array elements within process substitution bash

I've got a text file which looks like this: b4238ca2-cb8d-11e4-8731-1681e6b88ec1,https,username,password,ipaddress b4238f0e-cb8d-11e4-8731-1681e6b88ec1,https,username,password,ipaddress ...
1
vote
3answers
117 views

Store stdout and stderr in file, then recreate the output later

I've redirected output to a file like so: $ ./test.bash 2> >(sed 's/^/stderr: /' >> output) > >(sed 's/^/stdout: /' >> output) $ cat output stdout: Hello World! stderr: ...
11
votes
2answers
393 views

find out which file descriptors share the same “open file description”

If I do (in a Bourne-like shell): exec 3> file 4>&3 5> file 6>> file File descriptors 3 and 4, since 4 was dup()ed from 3, share the same open file description (same properties, ...
4
votes
1answer
682 views

Why did sshd delete my /dev/zero?

When I do lsof +c 0 | grep /dev/zero, I see the following two lines: sshd 19064 root DEL REG 0,4 497862 /dev/zero sshd 19064 root DEL REG 0,4 498725 /dev/zero ...
3
votes
5answers
786 views

Reading from file descriptor fails

This question is about reading and writing on a file descriptor. See the following example: #!/bin/sh file='somefile' # open fd 3 rw exec 3<> "$file" # write something to fd 3 printf ...
3
votes
1answer
101 views

termios settings after closing file

Are the settings altered by functions from termios.h kept after file is closed and open again? I want to use serial communication in a higher level language (Racket) which exposes only reading and ...
2
votes
1answer
199 views

Behaviour of 1>&0 in bash

So I am trying to learn more about file descriptors and their redirections. At the moment I am exploring an edge case of doing 1>&0 and I cannot quite understand what is happening there. $ ...
4
votes
2answers
1k views

How does Bash get the output of an executed program?

When I execute a program in Bash, for example, [ls][2], it sends its output to standard output (fd &1). And the ouput of the executed program is displayed in the terminal. How does Bash/terminal ...