Questions tagged [file-descriptors]

The tag has no usage guidance.

40 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
404 views

Find number of duplicate file descriptors on Linux

Given a file descriptor, is there a way in Linux to find out how many other file descriptors refer to the same file description (i.e. how often dup was called, not how often open was called)? I do ...
4
votes
0answers
672 views

Which socket is gnome-shell reading from continuously?

strace shows that the GNOME shell is continuously trying to read from a socket, which is often not available (or doesn't contain any data to read from): strace -p gnome-shell-pid -e trace=recvfrom ...
3
votes
0answers
31 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
1answer
106 views

concurrent processing in bash using process expansion, and redirection

Apart from possible races that have to be controlled by using proper synchronisation, it's possible in bash to feed a data source concurrently into multiple pipelines and collect all their outputs ...
2
votes
0answers
41 views

Get the path of song playing in VLC using python script

I am trying to get the path of song playing in VLC using python script. I have already find out the Process ID of vlc using pgrep -x vlc And I can also display the all file descriptors of vlc ...
2
votes
1answer
128 views

Does fd number of various shells fixed?

Let's say: xb@dnxb:/tmp$ echo 'ls -l /proc/$$/fd | grep a.sh' > a.sh; \ > while IFS='' read -r f; do \ > echo "$f"; "$f" a.sh; \ > done < <(tail -n +2 /etc/shells) /bin/sh lr-x------...
2
votes
0answers
233 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 ...
2
votes
1answer
467 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
1answer
453 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
1
vote
1answer
39 views

Redirection to named file descriptor buggy inside functions

Bash has a feature where it will pick a file descriptor number for you and assign it to a variable. $ exec {fd}>foo.txt $ echo "$fd" 11 $ echo "bar" >&$fd $ cat foo.txt bar This feature ...
1
vote
0answers
201 views

Listen in to data read from file descriptor to ttyS

I have a serial device under /dev/ttyS0 and an application that is reading from the serial device (but not writing to it). I wanted to listen in to the data that is coming in on the serial device but ...
1
vote
0answers
177 views

Bind an existing process to a socket

I want to bind an existing process to a socket listenning on a specific port with nc and send input to it (a python interactive shell, an editor...) whatever process, just send a pid and bind it, ...
1
vote
0answers
223 views

correct syntax for use of file descriptors with imagemagick

According to the ImageMagick manual, file descriptors are supported as of v.6.4.9-3. I am running v.6.9.7-4. However, I have been able to determine the correct syntax. Examples tried: convert 'xc:...
1
vote
0answers
411 views

Read from an arbitrary fd of a running process

I have two processes A and B, communicating over a pipe. I would like to be able to read from that pipe, using lsof I can easily find the right fd, unfortunately tail -f /proc/$pid/fd/$fd doesn't seem ...
1
vote
0answers
61 views

pv working with existing PID doesn't work with -s option

I would like to both use -d and -s option while calling pv. I tried as below: $ cat -n /tmp/x.py 1 import time 2 import threading 3 import sys 4 5 def w(): 6 ...
1
vote
0answers
665 views

How to fork a ffmpeg stream in order to read it with ffplay?

Say I create an encrypted webcam capture ffmpeg -f alsa -ac 2 -i plughw:0,0 \ -f video4linux2 -s vga -i /dev/video0 \ -f ogg >(openssl enc -k $PASSWORD -aes-256-cbc -out webcam.aes-256-cbc How ...
1
vote
1answer
626 views

where does go data written to file descriptor that was never opened

I have output captured by following command: $ strace -f -e trace=process,socketpair,open,close,dup,dup2,read,write -o rsync.log rsync -avcz --progress src/ dst/ it is a bit long so I've uploaded it ...
1
vote
2answers
328 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 ...
0
votes
0answers
31 views

File descriptors potential conflict

Context I'm processing data stored into files using a sequence of command line tools. In order to automate this process, I wrote a bash script chaining theses tools, the result of each tool being fed ...
0
votes
0answers
25 views

Understanding anonymous pipe ID

I'm currently debugging a system which has a resource leak. It seems that we have too many pipse open. When I go the my /proc/PROC_ID/fd I see the list of pipes l-wx------ 1 root root 64 Jun 30 12:32 ...
0
votes
0answers
34 views

Separate stdout of an application

I have an application that takes a few command line parameters, then prints some text to the terminal, then starts writing data to a file. It has a parameter I can use to define the file name to write ...
0
votes
1answer
15 views

Process substitution to script in order to monitor iotop

I am actively trying to get the output of the iotop for monitoring. As you know, the iotop is interactive, meaning that once started, it'll provide live updates on disk usage on the system. I'm ...
0
votes
0answers
15 views

Locale does not work with “file” command output

I have some JPEG files with Description metadata I added in MAC OS. exiftool (in MAC) displays them in correct locale. I copied those files to a Raspbian OS. From command line or bash script ...
0
votes
0answers
26 views

Monitoring data flow to /dev/null for a given process

I have a process which reads out data from a custom PCI-e device using a custom driver. The program takes a file descriptor as an argument and writes the raw data to it. I would like to test the data ...
0
votes
1answer
310 views

Maximum value for /proc/sys/fs/file-max

Today my server crashed with Too many open files in system: but I already have high values, what is a maximum value for this? I feel like there aren't good results on google for this, explaining ...
0
votes
0answers
37 views

Is a mmaped file considered an open file in linux/unix?

Hi I feel confused about open file and mmapped file. I know that if a file is accessed using system call such as read/write will return a file descriptor, and be considered as an open file? How about ...
0
votes
0answers
273 views

Cannot pass argument through /proc/<pid>/fd/0

I have written a basic C++ program as such: #include <sstream> #include <unistd.h> #include <cstdio> #include <iostream> int main(void) { int foo; std::cin >> foo; ...
0
votes
1answer
104 views

Number of file descriptors - pidstat

As mentioned here: On RHEL 7.x, below command: pidstat -C syslog-ng -v does not recognise -v option Alternative: There are two process 417880 & 417881 for syslog-ng: # ls /proc/`pidof syslog-...
0
votes
1answer
119 views

How does the act of closing shared file descriptors with a write-blocked process cause it to unblock?

Given multiple processes, forked from a parent process with shared file descriptors (representing STDOUT/STDERR), if one of the processes writes to STDOUT and exceeds the ~64K buffer it will block (as ...
0
votes
0answers
304 views

ss command: file descriptor information when using the -p option

In ss command, when using the -p option, this presumably provides info about the process (owner, pid an fd) root@Cassiopeia:~# ss -tap | tail -1 ESTAB 0 0 [2a0i:527:9981:8511:f64e:...
0
votes
1answer
208 views

Change stdout/stderr output device

By default if we run foo(){ echo "myfoo" } it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't ...
0
votes
0answers
56 views

In cron, /usr/bin/paplay does not display stderr

My PC's pulse audio dies whenever I open and close virtualbox windows in a certain situation. So I tried to monitor the audio state by crontab -e. Usually, in the commandline, $ paplay beep.wav &...
0
votes
0answers
251 views

Creating an exact copy of a whole process?

fork() forks a process, but it will not copy all of its threads; nor will it create a clone of all its fds: the fds are shared between parent and child. I want a way of do a complete fork. So after I ...
0
votes
1answer
54 views

Can you seek to a filehandle owned by another process as root?

There is a method to seek with a filehandle in C, int fseek(FILE *stream, long offset, int whence); There is also a file in fdinfo for each file descriptor, cat /proc/self/fdinfo/2 pos: 0 flags: ...
0
votes
0answers
396 views

/var/log mounted as a tmpfs failing to get umounted on FreeBSD

I have /var/log mounted as a tmpfs, where log files are synced periodically to the disk by the cron on FreeBSD. The process is done by the rc script. I am mounting it like: mount -t tmpfs -o nosuid,...
0
votes
0answers
1k views

Writting to a Tun/Tap interface

Recently I've been using a tun interface to redirect the Internet traffic through my methods. To do so, I followed this tutorial. My idea is to have a program which receives the IP packets that go to ...
0
votes
1answer
276 views

create a Virtual server in virtualmin: mailbox failed, Bad File Descriptor

I'm trying to create a Virtual server in virtualmin and everytime i click in create it displays an error : Creating mailbox for administration user .. .. mailbox failed : Failed to write to /home/...
0
votes
0answers
142 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 piped ...
0
votes
1answer
599 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
votes
2answers
52 views

Shell script to match row number from one file and put it as comments in another file when match

I have two files. The content of both files has dynamic and generated by the system when required. The first file contains the meaning for specific row number as below : head simdb.txt MSISDN ...