pipe

is it safe to read the pipe when the other side is writing to it?

fSuccess = ReadFile( hPipe, // pipe handle chBuf, // buffer to receive reply BUFSIZE*sizeof(TCHAR), // size of buffer &cbRead, // number of bytes read NULL); // not overlapped If not safe, how can I ensure the other side is not writing when reading a pipe in windows? ...

Is it viable to do video streaming via pipe in windows?

Is the pipe efficient enough to continuously pass video streams to other applications? If yes,can you provide a sample code in c/c++? ...

Running piped subprocesses gives different result when the launch order changes ?

Hello, I'm running a pipe of commands from a python3 program, using subprocess.*; I didn't want to go trough a shell, for I'm passing arguments to my subcommands, and making sure these would not be misinterpreted by the shell would be nightmarish. The subprocess doc gives this example of how to do it: p1 = Popen(command1, stdout=PIPE)...

Detect if stdin is a tty device (terminal) or pipe in PHP?

I wrote a php script. I want it show help message when called with standard input connected to a tty device (terminal) before reading and executing interactively, but dont show when called with a file or stream from pipe as standard input. Is there a way to detect this from PHP? ...

Broken Pipe when Using Python Multiprocessing Managers (BaseManager/SyncManager) to Share Queue with Remote Machines

In the last month, we've had a persistent problem with the Python 2.6.x multiprocessing package when we've tried to use it to share a queue among several different (linux) computers. I've posed this question directly to Jesse Noller as well since we haven't yet found anything that elucidates the issue on StackOverflow, Python docs, sour...

Regex Pipe bar question in PHP

I have a line of text that looks like "...X...Y...", where X and Y are both either Ok, Empty, or Open. Using PHP, I'm trying to use preg_match() to figure out what each one is. $regex = '/(Ok|Open|Empty)/'; preg_match($regex, $match, $matches); print_r($matches); However, in the case that X is "Empty", and Y is "Ok", the following li...

splice() from pipe to TCP buffered?

xpost from linuxquestions.org, sorry... I wrote a small test program to see if a simple proxy would benefit from using splice() but it always takes 200ms for the data that I spliced from a pipe to a TCP socket to be read from the other end of the socket. Here is the Perl program to test it: package test_pipes_2; use strict; use warnin...

How do I redirect output of nested function calls in bash?

I have a bash script that has a few functions which are all called within 1 function. How can I pipe all the output from all the functions up to the main one? I'll be using tee as well to display that output to term and to a log file. func 1 func 2 func 3 func 1 func 4 func 2 func 3 call func 4 # i want to grab it here...

How do I do a non-blocking read from a pipe in Perl?

I have a program which is calling another program and processing the child's output, ie: my $pid = open($handle, "$commandPath $options |"); Now I've tried a couple different ways to read from the handle without blocking with little or no success. I found related questions: perl-win32-how-to-do-a-non-blocking-read-of-a-filehandle-f...

Cucumber: pipe output without losing color

I'm using cucumber to run some tests. It colorizes its output using ANSI escapes. This is great, but currently its producing more output than I care about, and shoving things I do care about off the screen. There doesn't seem to be a way to eliminate the other lines from within cucumber, but I can pipe the output through grep to pare ...

Redirecting forked process output to parent process in C

What I am implementing is a (simpler) version of bash. One of the tasks is to accept the command : $ bg <command> <arguments> This will then fork a new process and then run execvp() in the new process using <command> and <arguments> as parameters. The problem is that when I capture the output from the child process, I use pipe(), an...

Stdout captured from pipe in Python is truncated

I want to capture the ouput of dpkg --list | grep linux-image in Python 2.6.5 on Ubuntu 10.04. from subprocess import Popen from subprocess import PIPE p1 = Popen(["dpkg", "--list"], stdout=PIPE) p2 = Popen(["grep", "linux-image"], stdin=p1.stdout, stdout=PIPE) stdout = p2.communicate()[0] The content of stdout is: >>> print stdou...

How do I close a Python 2.5.2 Popen subprocess once I have the data I need?

I am running the following version of Python: $ /usr/bin/env python --version Python 2.5.2 I am running the following Python code to write data ...

Can popen() make bidirectional pipes like pipe() + fork()?

I'm implementing piping on a simulated file system in C++ (with mostly C). It needs to run commands in the host shell but perform the piping itself on the simulated file system. I could achieve this with the pipe(), fork(), and system() system calls, but I'd prefer to use popen() (which handles creating a pipe, forking a process, and...

(c/c++) trying to force EOF from parent process sending input to child process

i have a very simple c/c++ program that forks a child process to execute another program, and then sends some data to that child program, and waits for the response. the child program reads from stdin and waits for EOF before it continues. my problem is, the child program receives the initial input from the pipe writing, but it never s...

Named Pipe ReadFile

My Application reads from a Named Pipe and the Problem is, ReadFile returns after the buffer is full or a timeout elaps. I wait for the last bytes to read up to 20 Seconds. Ich have test ist with smaller buffer, but Windows set buffer always to 1020 Bytes. I can't manipulate the Pipe on the other side. The Pipe runs on local Computer. If...

redirect or pipe file to standard out

How do u redirect a small(<20k) file to be piped to another program, so that it is never written to disc. You could use cfront and gcc as an example. Any example will do as long as you are redirecting something that normally outputs a file to something that usually accepts a file. You could could use any script or shell, but I would pr...

Reading from pipe using poll

Hi im trying to read data from pipe using poll, here is code: #include <stdio.h> #include <fcntl.h> #include <poll.h> #define MAX_BUFF_SIZE 128 int main(void){ char buff[MAX_BUFF_SIZE]; char *buf; int fd,ret,len; struct pollfd fdinfo[1]; if((fd = open("/home/s/pipe", O_RDONLY)) == NULL) { printf("Error Ope...

Linux: Pipe into Python (ncurses) script, stdin and termios

Hi all, Apparently this is almost a duplicate of "Bad pipe filedescriptor when reading from stdin in python - Stack Overflow"; however, I believe this case is slightly more complicated (and it is not Windows specific, as the conclusion of that thread was). I'm currently trying to experiment with a simple script in Python: I'd like to...

Why doesn't my Perl pipe to zcat die if the file is not there?

If my gz file does not exist, why doesn't it DIE? $ cat test.pl open(FILE, "zcat dummy.gz |") or die "DIE"; $ ./test.pl zcat: dummy.gz: No such file or directory If I read a file normally, it works as expected: $ cat test2.pl open(FILE, "dummy.gz") or die "DIE"; $ ./test2.pl DIE at ./test.pl line 2. ...