10,351 questions
0
votes
0
answers
106
views
How efficient are pipes and threads in C compared to regular function calls or pure sequential code? [closed]
I’m currently studying Operating Systems at college, and my professor has started teaching us about threads and pipes in C.
His teaching style is very practical — he expects us not only to understand ...
4
votes
1
answer
105
views
Understanding usage of withFileBlocking with named pipes
The following program
assumes that /path/to/mypipe is a named pipe, e.g. created via mkfifo /path/to/mypipe, with no readers/writers waiting yet,
runs two threads, of which
the main thread keeps ...
3
votes
2
answers
95
views
Why doesn't readFile block on unix pipe in which no write has happened yet?
If in a terminal I enter
mkfifo /tmp/pipe
echo hello > /tmp/pipe
(which blocks) and in another I run the haskell program
main = readFile "/tmp/foobar" >>= putStr
then I see it ...
0
votes
2
answers
149
views
Output stderr to terminal and stdout+stderr to file [duplicate]
From a command I want to redirect stderr to tty and stdout+stderr to a file. How can I do that?
e.g. for this:
cmd.bash
#!/usr/bin/bash
echo "Hello World"
echo "this is an error" &...
1
vote
1
answer
80
views
How to detect pipe close when reading text by line in Python
I have been having a lot of trouble reading text a line at a time from a pipe in Python and determining when the socket has been closed on the writing end. I have had the problem when communicating ...
3
votes
1
answer
183
views
Pipes Aren't Working: C Programming in the Windows Console [closed]
I've written this small program in C, which intends to read stdin line-by-line and finally echo each line back to stdout. It is designed to stop reading input when either EOF is detected or a blank ...
2
votes
2
answers
93
views
Does setvbuf(_IONBF) disable pipe blocking?
An MRE will be tricky here because this relies on (a very simple) secondary terminal executable, but I'll try my best:
Windows 11, WoW64 (32-bit compatibility) executable mode
c99
An MSVC-like (but ...
1
vote
1
answer
85
views
magrittr pipe placeholder doesn't work when calculating expression [duplicate]
Why {magrittr}'s pipe placeholder doesn't work when used in artihmetic expressions?
c(10,22,35,46) %>% .[1] # 10
c(10,22,35,46) %>% .[2] # 22
c(10,22,35,46) %>% (.[2] - .[1]) # Error: object '...
4
votes
1
answer
113
views
How to populate global variable from function which is in a pipe?
I would like to have function change value of global variable, but it fails when the function is used in a pipe:
#!/bin/bash
declare GVAR="abc"
func1() {
read GVAR
echo>...
3
votes
2
answers
130
views
Why does "pip list" not like broken pipes on the bash command line?
I'm using a bash terminal.
I just wanted to peek at the first few names of installed python packages:
pip list | head -n5
And got an error message:
Package Version
------------------ ------...
1
vote
1
answer
133
views
Why does np.fromfile fail when reading from a pipe?
In a Python script, I've written:
# etc. etc.
input_file = args.input_file_path or sys.stdin
arr = numpy.fromfile(input_file, dtype=numpy.dtype('f32'))
when I run the script, I get:
$ cat nums.fp32....
0
votes
1
answer
168
views
How to write data to a specific fd using Python Pwntools
I'm trying to use pwntools's process and to write a string to a specific fd
In the documentation, there is a parameter to process of stdin and stdout but I do not understand how to use it correctly.
I ...
1
vote
1
answer
39
views
Is there any way to show subprocess output in spyder console?
I'm computing neural networks with several .py files in spyder. I could sequencely execute them in spyder. However, the console do not show any thing like single file execution.
For example, this is ...
2
votes
1
answer
79
views
Passing two named pipes as input to ffmpeg using python
I have two av streams, one video and one audio, i'm trying to pipe both as inputs to ffmpeg
os.mkfifo(VIDEO_PIPE_NAME)
os.mkfifo(AUDIO_PIPE_NAME)
ffmpeg_process = subprocess.Popen([ "ffmpeg&...
3
votes
1
answer
74
views
How to have foreground tasks logged to stdout and a logger, background tasks only to the logger?
I'm trying to achieve the following:
A script shall echo some strings and execute some fast returning commands and I want to see all it's stderr and stdout output on stdout and in syslog (using ...
-2
votes
2
answers
126
views
Process many files in bash while simultaneously updating a progress bar
I am trying to run a function once for each file from a large list that I am piping in.
Here is some example code, here just grepping in the files whose names are coming from stdin.
In my real code I ...
4
votes
1
answer
190
views
Secure way to forbid a function to write to stdout
(if you suspect a XY problem, see details of what I want to do below)
I need a way to automatically test functions (written by students during an exam) to check that they are behaving correctly. The ...
2
votes
1
answer
69
views
awk: Using getline to pipe the output of a command into an awk variable doesn't see the output
My actual problem is that the input to an awk program is a file where some field in every line contains a filename, and I need to put the filesize of the file with that name into an awk variable.
Here ...
0
votes
1
answer
61
views
Pipe from 'if' block result in script being terminated with SIGTERM
I'm having this weird issue that I've been staring at for a few hours now and I can't seem to figure out whats wrong. I'm writing a dependency management system for a larger project and one of the ...
0
votes
1
answer
131
views
Reference the current state of a piped object in R pipe subfunction
I want to convert a column into a factor, and order the levels based on a different column. This works fine if I'm using the original object for the levels, e.g. below, the input object (iris) is ...
0
votes
0
answers
58
views
pwntools [Errno 24] Too many open files [-] Starting local process
I'm having an issue with some code I'm writing. I'm getting this pwntools error about too many files being open.
My code looks like.
for a in range(0,2**3360):
try:
with open(&...
2
votes
3
answers
116
views
How can I lazily forward text to shell program and lazily get output back from it?
(This is a follow up to a previous question.)
I want to write a Haskell program that forward its standard input to grep's (or another Linux program, fwiw) standard input, and then collects grep's ...
0
votes
0
answers
41
views
What's the deal with the cl_mem_flags used to create an OpenCL pipe?
The API call for creating a pipe in OpenCL 2.0 and later is:
cl_mem clCreatePipe(
cl_context context,
cl_mem_flags flags,
cl_uint pipe_packet_size,
cl_uint pipe_max_packets,
const ...
5
votes
1
answer
213
views
Does the `boost::asio::readable_pipe::read()` member function exist?
I am trying to build some example code shown on Boost web site, but a member function is used which does not seem to be part of Boost:
#include <string>
#include <iostream>
#include <...
0
votes
0
answers
69
views
producer- consumer problem using multiprocessing in python
I am trying to implement this problem using multiprocessing and pipe as the communication between processes strategy using the following method:
The producer uses a counter, pro_count, to track the ...