You can use command lsof to get file descriptors for all running processes, but what I would like to do is to close some of those descriptors without being inside that process. This can be done on Windows, so you can easily unblock some application.
Is there any command or function for that?
close() closes a file descriptor, so that it no longer refers to any file and may be reused. Any record locks (see fcntl(2)) held on the file it was associated with, and owned by the process, are removed (regardless of the file descriptor that was used to obtain the lock).
Named streams are useful for passing file descriptors between unrelated processes on the same machine. A user process can send a file descriptor to another process by invoking the I_SENDFD ioctl(2) on one end of a named stream.
Additionally, you can use shortcut methods. Press the [Esc] key and type Shift + Z Z to save and exit or type Shift+ Z Q to exit without saving the changes made to the file.
Use "pgrep" and "pkill" Linux Force Kill Commands As with the kill command, this should close the Linux process within around 5 seconds.
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 close(0):
(gdb) p close(0) $1 = 0 (gdb) c Continuing. Program exited with code 01. (gdb)
In the first shell I get this output:
cat: -: Bad file descriptor cat: closing standard input: Bad file descriptor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With