file-descriptor

User space defined file descriptor (Linux)

强颜欢笑 提交于 2019-12-11 02:20:07
问题 Is it possible (specifically in Linux) to make a file descriptor from user-provided functions like the following? ssize_t (*write)(int fd, const void *buf, size_t count); ssize_t (*read)(int fd, void *buf, size_t count); (and maybe some more functions, like close() and/or something for polling) It should look for the OS as a normal FD number, but be handled by the user-provided callbacks (as above) rather than by the OS itself. The reason why I ask is to know whether it is possible to

Expected consumption of open file descriptors in Hadoop 0.21.0

不想你离开。 提交于 2019-12-10 23:16:02
问题 Given Hadoop 0.21.0, what assumptions does the framework make regarding the number of open file descriptors relative to each individual map and reduce operation? Specifically, what suboperations cause Hadoop to open a new file descriptor during job execution or spill to disk? (This is deliberately ignoring use of MultipleOutputs, as it very clearly screws with the guarantees provided by the system.) My rationale here is simple: I'd like to ensure each job I write for Hadoop guarantees a

How to pass net.Listener()'s FD to child process safely?

一笑奈何 提交于 2019-12-10 17:25:03
问题 I've been stucked with this issue for hours: I have a main process served as a TCP server, the main process call Fork(), pass its net.Listener()'s FD to child process. Then child process can use net.Filelistener() to inherit this FD. I have researched this issue through many open-sourced codes, also did some experiments. But unfortunately none of these solutions satisfy me for now since they are not portable, you also need many low-level jobs which are dangerous. If there's any solution to

Opening and writing to multiple files in C

一笑奈何 提交于 2019-12-10 17:06:30
问题 The input is a single file of around 70GB whose every single line contains client information. A program reads this file and makes one file for each client. There are 8000 clients but we have to provision for 40000 clients. Currently the UNIX sort command is used to sort the file by client and then client files are written. This way the program has only a single file handler open for creating the files. We do not want to use the sort command as it consumes around 1.5 hours. This would however

Pass handle down pipeline

馋奶兔 提交于 2019-12-10 15:18:10
问题 Say I have node foo.js | node bar.js is there a way to pass a handle on foo's stdin to bar.js? I have a rare case where I'd like to communicate backwards in the pipeline. At the least I know that I could send node bar.js the pid of node foo.js . Given that pid, on *nix, I should be able to write to foo's stdin using: /proc/<pid>/fd/0 but is there a way to do the same on MacOS? 回答1: So there are different ways of doing it. Approach 1 - IOCTL This is inspired from https://stackoverflow.com/a

Opening pipe connection to a file descriptor in C#

你离开我真会死。 提交于 2019-12-10 15:08:45
问题 I have a legacy app where it reads message from a client program from file descriptor 3. This is an external app so I cannot change this. The client is written in C#. How can we open a connection to a specific file descriptor in C#? Can we use something like AnonymousPipeClientStream()? But how do we specify the file descriptor to connect to? 回答1: Unfortunately, you won't be able to do that without P/Invoking to the native Windows API first. First, you will need to open your file descriptor

In C, are file descriptors that the child closes also closed in the parent?

≡放荡痞女 提交于 2019-12-10 15:02:38
问题 As far I understand it, Fds are integers that are used to look up the open files in the kernel's file description table. So therefore if you have a code segment like this: int fd[2], temp1, temp2; pipe(fd); temp1 = fd[0]; temp2 = fd[1]; close(temp1); close(temp2); All the file descriptors to the pipe are closed and thus the pipe would no longer exist. Since FDs are simply ints, saying close(temp1) is identical to saying close(fd[0]) . In light of all this (and please let me know if I am

Program stuck, pipe file descriptor open when shouldn't?

三世轮回 提交于 2019-12-10 14:12:43
问题 I am creating a small shell that can read commands. When I run my program and type: "cat file.txt > file2.txt" it creates the file and then it gets stuck at the line: if(execvp(structVariables->argv[0], argv) < 0). (waiting for input/output??). If I end the program with ctrl + d I can see in my folder that the file is created but nothing has been written in it. (dupPipe is used to handle more commands, not yet used because of problem described above) if((pid = fork()) < 0) { perror("fork

QSerialPort effect on `/dev/ttyS*` after process end?

元气小坏坏 提交于 2019-12-10 13:45:43
问题 When a Qt app using QSerialPort experiences a non-clean shutdown (e.g. due to receiving and not handling SIGINT ), how is the file descriptor of the serial port affected? After running an app that opens a QSerialPort on /dev/ttyS0 , then quitting with Ctl-C , I am finding that cat < /dev/ttyS0 returns instantly (without printing anything) rather than waiting for data (as it usually does). I would expect that if this is due to an open file handle left hanging around, it would show up in the