fifo

Prevent FIFO from closing / reuse closed FIFO

时光总嘲笑我的痴心妄想 提交于 2019-12-20 11:44:11
问题 Consider the following scenario: a FIFO named test is created. In one terminal window (A) I run cat <test and in another (B) cat >test . It is now possible to write in window B and get the output in window A. It is also possible to terminate the process A and relaunch it and still be able to use this setup as suspected. However if you terminate the process in window B, B will (as far as I know) send an EOF through the FIFO to process A and terminate that as well. In fact, if you run a process

FIFO serial queue using GCD

岁酱吖の 提交于 2019-12-20 09:51:05
问题 I am trying to create a (network) synchronized array for the company I work for. While the networking part works fine, I have dwelled into an issue. My wish was to create a new queue using dispatch_create_queue , to which I would add two blocks that are not to run on the main thread, but in a serial manner, meaning that first the first block has to run, then the second, and never in parallel. I've read the apple documentation, but it is confusing to say the least. When I create my queue using

FIFO pipe only reads after write end has closed

时光总嘲笑我的痴心妄想 提交于 2019-12-19 10:40:09
问题 I'm trying to create a FIFO pipe between a python file and C file, but the issue is that when reading in the input from the C file, getline blocks until the writer end (in the python file) closes. C file: char fifo_emg[] = "emg"; mkfifo(fifo_emg, S_IRWXU); int fd_emg = open(fifo_emg, O_RDONLY); FILE* fp = fdopen(fd_emg, "r"); char *line = NULL; size_t len = 0; ssize_t _read; printf("Both ends open. Reading commands...\n"); while ((_read = getline(&line, &len, fp)) != -1) { printf("Comamnd: %s

Can Sql Server BULK INSERT read from a named pipe/fifo?

瘦欲@ 提交于 2019-12-18 16:45:20
问题 Is it possible for BULK INSERT/bcp to read from a named pipe, fifo-style? That is, rather than reading from a real text file, can BULK INSERT/bcp be made to read from a named pipe which is on the write end of another process? For example: create named pipe unzip file to named pipe read from named pipe with bcp or BULK INSERT or: create 4 named pipes split 1 file into 4 streams, writing each stream to a separate named pipe read from 4 named pipes into 4 tables w/ bcp or BULK INSERT The closest

Is there a FIFO stream in Scala?

对着背影说爱祢 提交于 2019-12-18 12:58:06
问题 I'm looking for a FIFO stream in Scala, i.e., something that provides the functionality of immutable.Stream (a stream that can be finite and memorizes the elements that have already been read) mutable.Queue (which allows for added elements to the FIFO) The stream should be closable and should block access to the next element until the element has been added or the stream has been closed. Actually I'm a bit surprised that the collection library does not (seem to) include such a data structure,

Is there a queue implementation?

纵然是瞬间 提交于 2019-12-18 10:16:09
问题 Can anyone suggest Go container for simple and fast FIF/queue, Go has 3 different containers: heap , list and vector . Which one is more suitable to implement a queue? 回答1: Either vector or list should work, but vector is probably the way to go. I say this because vector will probably allocate less often than list and garbage collection (in the current Go implementation) is fairly expensive. In a small program it probably won't matter, though. 回答2: In fact, if what you want is a basic and

FIFOs implementation

霸气de小男生 提交于 2019-12-18 04:23:07
问题 Consider the following code: writer.c mkfifo("/tmp/myfifo", 0660); int fd = open("/tmp/myfifo", O_WRONLY); char *foo, *bar; ... write(fd, foo, strlen(foo)*sizeof(char)); write(fd, bar, strlen(bar)*sizeof(char)); reader.c int fd = open("/tmp/myfifo", O_RDONLY); char buf[100]; read(fd, buf, ??); My question is: Since it's not know before hand how many bytes will foo and bar have, how can I know how many bytes to read from reader.c? Because if I, for example, read 10 bytes in reader and foo and

FIFO class in Java

对着背影说爱祢 提交于 2019-12-17 15:35:27
问题 I want to implement FIFO through a class in Java. Does such a class already exist? If not, how can I implement my own? NOTE I found a class here http://www.dcache.org/manuals/cells/docs/api/dmg/util/Fifo.html, but it doesn't contain dmg.util.*. I don't know if such a package even exists. 回答1: You're looking for any class that implements the Queue interface, excluding PriorityQueue and PriorityBlockingQueue , which do not use a FIFO algorithm. Probably a LinkedList using add (adds one to the

How do I perform a non-blocking fopen on a named pipe (mkfifo)?

我的未来我决定 提交于 2019-12-17 09:51:41
问题 If I have a program which creates and attempts to open a named pipe using mkfifo, how can I open a pipe for reading or writing without blocking? Specifically, I'm writing a C program which can be run with or without a gui (written in Java). In the C program, I successfully create the named pipes using mkfifo, however when I do FILE* in = fopen(PIPE_IN, "r"); /* Where PIPE_IN is the filename*/ fopen doesn't return until the GUI opens that pipe for writing. What I wish to do is have that pipe

Which STL container should I use for a FIFO?

本秂侑毒 提交于 2019-12-17 08:11:16
问题 Which STL container would fit my needs best? I basically have a 10 elements wide container in which I continually push_back new elements while pop_front ing the oldest element (about a million time). I am currently using a std::deque for the task but was wondering if a std::list would be more efficient since I wouldn't need to reallocate itself (or maybe I'm mistaking a std::deque for a std::vector ?). Or is there an even more efficient container for my need? P.S. I don't need random access