Check the open FD limit for a given process in Linux
Count the entries in /proc/<pid>/fd/. The hard and soft limits applying to the process can be found in /proc/<pid>/limits.
Count the entries in /proc/<pid>/fd/. The hard and soft limits applying to the process can be found in /proc/<pid>/limits.
I found an open source project for implementing what I was trying. It processes the video with metadata through an IP camera. Although it does not send video directly to a phone, it does broadcast video for various devices to watch. The source code can be found at the following project page http://code.google.com/p/ipcamera-for-android/. With Android … Read more
Yes, creating fake BUILD_ID for process tells Jenkins to ignore this process during detection spawned processes, so this process will be not killed after finishing job. Usage: Enter BUILD_ID=dontKillMe before your command, for example into Execute shell build step: BUILD_ID=dontKillMe nohup ./yourStartScript.sh & Note: See also nohup
It’s important to distinguish between the file descriptor, which is a small integer that the process uses in its read and write calls to identify the file, and the file description, which is a structure in the kernel. The file offset is part of the file description. It lives in the kernel. As an example, … Read more
You get this error message if a Python file was closed from “the outside”, i.e. not from the file object’s close() method: >>> f = open(“.bashrc”) >>> os.close(f.fileno()) >>> del f close failed in file object destructor: IOError: [Errno 9] Bad file descriptor The line del f deletes the last reference to the file object, … Read more
A file descriptor is a low-level integer “handle” used to identify an opened file (or socket, or whatever) at the kernel level, in Linux and other Unix-like systems. You pass “naked” file descriptors to actual Unix calls, such as read(), write() and so on. A FILE pointer is a C standard library-level construct, used to … Read more
File descriptors 0, 1 and 2 are for stdin, stdout and stderr respectively. File descriptors 3, 4, .. 9 are for additional files. In order to use them, you need to open them first. For example: exec 3<> /tmp/foo #open fd 3. echo “test” >&3 exec 3>&- #close fd 3. For more information take a … Read more
While portable, closing all file descriptors up to sysconf(_SC_OPEN_MAX) is not reliable, because on most systems this call returns the current file descriptor soft limit, which could have been lowered below the highest used file descriptor. Another issue is that on many systems sysconf(_SC_OPEN_MAX) may return INT_MAX, which can cause this approach to be unacceptably … Read more
You can go the other way: implement your own stream buffer that wraps a file descriptor and then use it with iostream instead of fstream. Using Boost.Iostreams can make the task easier. Non-portable gcc solution is: #include <ext/stdio_filebuf.h> { int fd = …; __gnu_cxx::stdio_filebuf<char> fd_file_buf{fd, std::ios_base::out | std::ios_base::binary}; std::ostream fd_stream{&fd_file_buf}; // Write into fd_stream. // … Read more
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