file-descriptor
Error with resque-web: Couldn’t get a file descriptor referring to the console
It’s probably trying to open the default browser and failing to do so. Try using: $ resque-web -L To avoid starting a browser.
How to write data to existing process’s STDIN from external process?
Your code will not work. /proc/pid/fd/0 is a link to the /dev/pts/6 file. $ echo ‘foobar’ > /dev/pts/6 $ echo ‘foobar’ > /proc/pid/fd/0 Since both the commands write to the terminal. This input goes to terminal and not to the process. It will work if stdin intially is a pipe. For example, test.py is : … Read more
Finding open file descriptors for a process linux ( C code )?
Here’s some code I used to use, I didn’t know about /proc/self (thx Donal!), but this way is probably more generic anyway. I’ve included the required includes for all the functions at the top. #include <string.h> #include <stdio.h> #include <dirent.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <sys/resource.h> #ifndef FALSE #define FALSE (0) #endif #ifndef … Read more
is it a good practice to close file descriptors on exit [closed]
The classic guide to POSIX programming “Advanced programming in UNIX environment” states: When a process terminates, all of its open files are closed automatically by the kernel. Many programs take advantage of this fact and don’t explicitly close open files. You did not mention the OS in your question but such behavior should be expected … Read more
Socket and file descriptors
Yes, sockets are also indices into the same table as files. At least for UNIX systems (like Linux and OSX), Windows is different, which is why you can’t use e.g. read and write to receive and send data. Each process has its own “file” descriptor table.
How to use a variable to indicate a file descriptor in bash?
The accepted answer is correct, but as of bash 4.1, you can use automatic file descriptor allocation, and in that case you don’t need eval: file=a exec {id}<>”$file” Then you can use it like this: echo test >&${id} or: fsck -v -f -C ${id} /dev/something
How to redirect an output file descriptor of a subshell to an input file descriptor in the parent shell?
BEWARE, BASHISM AHEAD (there are posix shells that are significantly faster than bash, e.g. ash or dash, that don’t have process substitution). You can do a handle dance to move original standard output to a new descriptor to make standard output available for piping (from the top of my head): exec 3>&1 # open 3 … Read more
How to close a file descriptor from another process in unix systems
I don’t know why you are trying to do this, but you should be able to attach to the process using gdb and then call close() on the fd. Example: In one shell: cat In another shell: $pidof cat 7213 $gdb -p 7213 … lots of output … (gdb) Now you tell gdb to execute … Read more