file-descriptor

Redirect stderr to stdout on exec-ed process from python?

In a bash script, I can write: exec 2>&1 exec someprog And the stderr output of someprog would be redirected to stdout. Is there any way to do a similar thing using python's os.exec* functions? This doesn't have to be portable, just work on Linux. ...

difference between file descriptor and file pointer

Hi all, I want to know the difference between the file descriptor and file pointer.And also which is efficient in scenarios. ...

bad file descriptor with close() socket (c++)

hi everybody! I'm running out of file descriptors when my program can't connect another host. The close() system call doesn't work, the number of open sockets increases. I can se it with cat /proc/sys/fs/file-nr Print from console: connect: No route to host close: Bad file descriptor connect: No route to host c...

Which tools to use and how to find file descriptors leaking from Glassfish?

We release new code to production every week and Glassfish hasn't had any problems. This weekend we had to move racks at our hosting provider. There were not any code changes (they just powered off, moved, re-racked and powered on) but we're on a new network infrastructure and suddenly we're leaking file descriptors like a sieve. So I...

Force blocking read after EAGAIN?

I have a file descriptor that is open for reading which may be non-blocking. What I need to do is simply read all data until reaching EOF and write that data to a writable file descriptor. As the process that performs this copying is not "aware" of anything that is going on around it, I don't think that I can do something useful while wa...

Is O_LARGEFILE needed just to write a large file?

Is the O_LARGEFILE flag needed if all that I want to do is write a large file (O_WRONLY) or append to a large file (O_APPEND | O_WRONLY)? From a thread that I read titled "Cannot write >2gb index file" on the CLucene-dev mailing list, it appears that O_LARGEFILE might be needed to write large files, but participants in that discussion a...

Is O_NONBLOCK being set a property of the file descriptor or underlying file?

From what I have been reading on The Open Group website on fcntl, open, read, and write, I get the impression that whether O_NONBLOCK is set on a file descriptor, and hence whether non-blocking I/O is used with the descriptor, should be a property of that file descriptor rather than the underlying file. Being a property of the file descr...

How to execute a program from file descriptor?

I need to execute a file when I only know the descriptor. It is also possible that there are no links to the file so finding out the name somehow is not an option. All the execve(), execvp(), etc functions take a file name. dlopen() also takes a name. Ugly solutions (like reading the file and calling some function pointer) are OK. ...

change file descriptor for socket in python

Hello everybody I'm trying to manually create the file descriptor associated with a socket in python and then loaded directly into memory with mmap. Create a file into memory with mmap is simple, but I can not find a way to associate the file with a socket. Anyone know how? thank you very much. ...

How to pass file descriptors from parent to child in python?

Hi, I am using multiprocessing module, and using pools to start multiple workers. But the file descriptors which are opened at the parent process are closed in the worker processes. I want them to be open..! Is there any way to pass file descriptors to be shared across parent and children? ...

How to check the number of open connections in node.js?

Hello there! I have a machine running node.js (v0.1.32) with a tcp server (tcp.createServer) and a http server (http.createServer). The http server is hit by long polling requests (lasting 50 sec each) from a comet based application on port 80. And there are tcp socket connections on port 8080 from an iphone application for the same pur...

How to determine if a file descriptor is seekable?

Is there any portable way (on POSIX systems) to determine if a file descriptor is seekable? My thought is to use lseek(fd, 0, SEEK_CUR); and check if the return value is -1, but I'm uncertain if this could give false negatives or false positives. Using fstat and making assumptions about what types of files are seekable/nonseekable does n...

ftell on a file descriptor?

Is there a way to do what ftell() does (return the current position in the file) on a raw file descriptor instead of a FILE*? I think there ought to be, since you can seek on a raw file descriptor using lseek(). I know I could use fdopen() to create a FILE* corresponding to the file descriptor, but I'd rather not do that. ...

specifying file descriptor number?

My understanding was that one could not control the file descriptor (integer) assigned by the OS when opening a new file using open(). How then is it possible in a bash shell to assign a specific file descriptor using a command like exec 5>&1 (I suppose I could find out by reading the bash sources...) ...

can a process create extra shell-redirectable file descriptors?

Can a process 'foo' write to file descriptor 3, for example, in such a way that inside a bash shell one can do foo 1>f1 2>f2 3>f3 and if so how would you write it (in C)? ...

Writing to multiple file descriptors with a single function call

I had a use case for a group chat server where the server had to write a common string to all clients' socket. I had then addressed this by looping through the list of file descriptors and writing the string to each of the file descriptors. Now I am thinking of finding a better solution to the problem. Is it possible to do this by a sin...

How can I detect when someone opens the slave side of a pty (pseudo-terminal) in Linux?

Having more than one process read from a serial device (/dev/ttyXX) makes it so that both processes can't get all of the data -- the data will be split between them in some way. I'd like to write a program that reads from a serial device, creates several master/slave pty pairs, and then allows programs that were made to read from the se...

Question about STDIN STDOUT STDERR

I'm designing a MIPS simulator in c++ and my simplified OS must be able to run stat() occasionally (when a program being executed on my simulator requires an input or an output or something.) The problem is, I need to be able to assert STDIN, STDOUT, and STDERR as parameters to stat "stat("stdin",buff)" where buff is the pointer to th...

How to Access File Descriptor of Open File

Is there any way to access the file descriptor of a file opened in c++? So ... #include <iostream> #include <fstream> using namespace std; int main() { ifstream inputFile( "file.txt",ios::in ); cout << inputFile.fileDesc << endl;//made up call return 0; } The question is, does something like fileDesc exist for...

How do I create a memory-mapped file without a backing file on OSX?

I want to use a library that uses file descriptors as the basic means to access its data. For performance reasons, I don't want to have to commit files to the disk each before I use this library's functions. I want to create (large) data blobs on the fly, and call into the library to send them to a server. As it stands, I have to write ...