The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
1answer
40 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
17 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
51 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?
1
vote
0answers
28 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 ...
8
votes
1answer
81 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
51 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, ...
1
vote
0answers
77 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 ...
1
vote
0answers
39 views

Why is there no basic limit in prctl - n process.max-file-descriptors for some processes?

Some flexlm processes which are running as non-user but are started during startup as init process are not having basic(soft limit). What does it mean? NAME PRIVILEGE VALUE FLAG ACTION ...
4
votes
5answers
287 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
24 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 ...
0
votes
2answers
73 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
53 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
25 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
124 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
135 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 ...
-1
votes
1answer
69 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
93 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
216 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
396 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
414 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
45 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
109 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. $ ...
3
votes
2answers
492 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 ...
1
vote
2answers
74 views

Map reading/writing a file to getting output from/sending input to a script?

Suppose I have two scripts, script1.sh and script2.sh. I am wondering if there is a way to make a filesystem interface such that, for example, I can go vim file and then have my system run script1.sh ...
2
votes
1answer
98 views

Capturing data from a Fluke 1620a via Bash /dev/tcp file descriptor

I am currently trying to develop a script that will connect to a Fluke DewK 1620a Themo-Hygrometer and pull the current temperature and humidity readings from the device. While these devices have a ...
2
votes
2answers
189 views

How to print total number of file descriptors with index 24

How can I print the total number of file descriptors with index 24 for all the running processes on Linux? I tried $ ls /proc/*/fd 2> errors.txt > stdout.txt | grep "^24" stdout.txt | wc -l ...
4
votes
2answers
329 views

How to read user input when using script in pipe

General problem I want to write a script that interacts with the user even though it is in the middle of a chain of pipes. Concrete example Concretely, it takes a file or stdin, displays lines ...
2
votes
1answer
33 views

Forcing write(2) to return 0

I am writing unit tests and would like to test some code's handling of the case where a call to write(2) returns zero. As ever, it would be nice to keep the test as authentic as possible. I can use a ...
3
votes
5answers
4k views

Stripping directory paths to get file names

What I am doing is converting mp3's with LAME. I already have an old script I wrote that works but I want to add to it this ability--to no longer delete the file but instead save it in a new root ...
50
votes
2answers
3k views

Is >&- more efficient than >/dev/null?

Yesterday I read this SO comment which says that in the shell (at least bash) >&- "has the same result as" >/dev/null. That comment actually refers to the ABS guide as the source of its ...
0
votes
1answer
81 views

How to find file/device given the resource ID on Linux?

On a gentoo Linux system I am printing the value of a file descriptor from within a PHP script yielding the following output: Resource id #1234 How to find the corresponding file/device given this ...
1
vote
2answers
414 views

Process substitution with input redirection

I am trying to understand input redirection in combination with process substituation. I am using bash 3 An example with tr is the following $ tr "o" "a" <(echo "Foo") tr: extra operand ...
6
votes
3answers
2k views

Why can't I `tail -f /proc/$pid/fd/1`?

I wrote a simple script which echo-es its PID: #/bin/bash while true; do echo $$; sleep 0.5; done I'm running said script (it says 3844 over and over) in one terminal and trying to tail ...
2
votes
1answer
90 views

Is there a system call to bind a file descriptor directly into another?

A read() & write() loop would probably be as good as what I'm looking for, but nevertheless is anything like that around or is it impossible because of an obstacle I didn't envisage ? I'm curious
7
votes
1answer
130 views

How can I send reads and writes on a single file descriptor to different places?

I have a Linux executable foo that reads input from fd 0 and writes output to fd 0 (not fd 1). This works just fine for interactive use in the terminal. From the shell command line, how can I execute ...
7
votes
3answers
707 views

How can a log program continue to log to a deleted file?

From the Unix Power Tools, 3rd Edition: Instead of Removing a File, Empty It section: If an active process has the file open (not uncommon for log files), removing the file and creating a new ...
5
votes
2answers
155 views

“command | less” vs “less <(command)”

A common "idiom" for viewing large amounts of command output is to pipe it to less, via command | less. However, it's also possible (perhaps only in bash, haven't tested in other shells) to use the ...
1
vote
2answers
75 views

What fd's are used when doing diff <(cat old) <(cat new)?

If I do: diff <(cat old) <(cat new) Hoe does that work internally for the diff program? And how I do the same trick with a bash script?
10
votes
2answers
1k views

stderr over ssh -t

This sends output to STDERR, but does not propagate Ctrl+C (i.e. Ctrl+C will kill ssh but not the remote sleep): $ ssh localhost 'sleep 100;echo foo ">&2"' This propagates Ctrl+C (i.e. ...
2
votes
0answers
21 views

Is it safe to create a regression test that relies on running out of file descriptor limit?

I'm writing a regression test for my modification of Nmap and I'm wondering if it's a good idea to create a test that would basically perform a large-scale connect() scan on 127.0.0.1/8, which would ...
2
votes
2answers
606 views

Any way in Bash to write to a file every X seconds without closing it?

The hardware watchdog on my system needs a 0 written to /dev/watchdog at less than 60 seconds interval or it will fire. The file handle must be kept open however or the watchdog is then disabled. ...
2
votes
1answer
759 views

closing the unwanted file descriptors

I am trying to understand how pipes work . This code snippet is from some website . So my understanding of the program goes like this : When we do pipe(fd) then fd[0]=3 and fd[0]=4 ( assuming only ...
3
votes
0answers
66 views

Some puzzles of how to close file descriptors on sh or bash [duplicate]

Question 1. What will happen if we close a input file descriptor as if it is a output file descriptor? (or vice versa). For Example, $ exec 5<&2 $ exec 5>&- In my linux box, ...
4
votes
2answers
2k views

Process substitution from curl to bash as root

I'm trying to run a script from URL as root with this command: sudo bash <(curl -s http://copy.com/gLVZIqUubzcS/popcorn) But I'm getting this error: bash: /dev/fd/63: Aucun fichier ou dossier ...
5
votes
2answers
1k 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, ...
2
votes
4answers
141 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?
3
votes
2answers
4k 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?
2
votes
2answers
282 views

Redirecting only stderr to a pipe

This code snippet is from Advanced Bash Scripting Guide. # Redirecting only stderr to a pipe. exec 3>&1 # Save current "value" of stdout. ls -l 2>&1 ...
5
votes
1answer
2k views

What does exec 3<&1 do?

I understand exec can do I/O Redirection on current shell level. but I only sees usage like exec 6<&0 # Link file descriptor #6 with stdin. # Saves stdin. exec 6>&1 # ...
0
votes
2answers
523 views

How to reset the file descriptor

I was trying to use file descriptor for printing the lines in the file #!/usr/bin/ksh exec 3<&0 exec 0< file.txt while read LINE do echo “$LINE” done and I am done with my code ,it ...