Sponsored Content
Top Forums Shell Programming and Scripting UNIX fifo concurrent read from a named pipe Post 303013484 by Scrutinizer on Thursday 22nd of February 2018 04:11:56 AM
Old 02-22-2018
  • You need a wait statement after the second readpipe.sh
  • echo var >> log.txt . The $ sign is left out of the variable expansion and you need to quote the variable.
  • Why are you appending instead of writing to the pipe
  • The first readpipe will read all there is in the pipe. The second one gets nothing

Last edited by Scrutinizer; 02-22-2018 at 05:18 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

Pipe & fifo....

Could someone Help me with this code please? #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <fcntl.h> #define SIZE_B 256 /*buffer's size */ #define NUM_ARG 20 /* max number of args for any command */ int... (4 Replies)
Discussion started by: M3xican
4 Replies

2. UNIX for Advanced & Expert Users

PIPE and FIFO buffer size

Hello! How I can increase (or decrease) the predefined pipe buffer size? Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

3. Shell Programming and Scripting

FIFO named pipes

Hi...Can anyone please guide me on FIFO Pipes in UNIX.I have lerant things like creating fifo pipes,using them for reads and writes etc.I want to know what is the maximum amount of memory that such a pipe may have? Also can anyone guide me on where to get info on this topic from? (1 Reply)
Discussion started by: tej.buch
1 Replies

4. UNIX for Dummies Questions & Answers

Named PIPE

Gurus, I've a File Transaction Server, which communicates with other servers and performs some processing.It uses many Named PIPE's. By mistake i copied a named PIPE into a text file. I heard that PIPE files shouldn't be copied.Isn't it? Since it's a production box, i'm afraid on... (2 Replies)
Discussion started by: Tamil
2 Replies

5. Shell Programming and Scripting

Reading from blocking fifo pipe in shell script

Hi!! I have a problem reading from a fifo pipe in shell script. The idea is simple, I have a C program with two pipe files: An input pipe I use to send commands in shell script to the C program (echo "command" > input.pipe) An output pipe that I read the result of the command also in... (4 Replies)
Discussion started by: victorin
4 Replies

6. UNIX for Dummies Questions & Answers

fifo or named pipe working?

Can someone explain to me the working of fifo() system call using simple C programs so that I can implement them in the UNIX environement? (1 Reply)
Discussion started by: lvkchaitanya
1 Replies

7. UNIX for Advanced & Expert Users

Why not SIGPIPE for readers of pipe/FIFO?

Hi This is a exercise question from Unix network programming vol2. Why the SIGPIPE signal is generated only for writers when readers disappear. why not it is generated for readers when writer disappears. I guess, if the writer didn't get any response like the reader gets EOF, it will... (4 Replies)
Discussion started by: kumaran_5555
4 Replies

8. Programming

Pipe & fifo size limit

Hi guys. 1. how much is the size of pipe?(i mean the buffer size) 2. is this size different in various UNIX derivations? 3. what happens if we write to a full pipe? does it block until get some free space(the other side receive data) or returns an error? 3. FIFO s are physical files on the... (2 Replies)
Discussion started by: majid.merkava
2 Replies

9. Shell Programming and Scripting

awk reading from named pipe (fifo)

I'm trying to read a fifo using awk and comming across some problems. I'm writing to the fifo from multiple processes invoked by GNU Parallel: mkfifo my_fifo awk '{ a = a + $2 } END { for (i in a) print i, a }' my_fifo | sort -nk1 > sorted_output grep -v '^@' massive_file | parallel... (3 Replies)
Discussion started by: nathanhaigh
3 Replies

10. UNIX for Beginners Questions & Answers

UNIX Pipe -Exit when there are no bytes to read

Hi All, I'm creating a program which reads millions of bytes from the PIPE and do some processing. As the data is more, the idea is to read the pipe parallely. Sun Solaris 8 See the code below: #!/bin/sh MAXTHREAD=30 awk '{print $1}' metadata.csv > nvpipe & while do ... (3 Replies)
Discussion started by: mr_manii
3 Replies
PIPE(2) 						      BSD System Calls Manual							   PIPE(2)

NAME
pipe -- create descriptor pair for interprocess communication SYNOPSIS
#include <unistd.h> int pipe(int fildes[2]); DESCRIPTION
The pipe() function creates a pipe (an object that allows unidirectional data flow) and allocates a pair of file descriptors. The first descriptor connects to the read end of the pipe; the second connects to the write end. Data written to fildes[1] appears on (i.e., can be read from) fildes[0]. This allows the output of one program to be sent to another pro- gram: the source's standard output is set up to be the write end of the pipe; the sink's standard input is set up to be the read end of the pipe. The pipe itself persists until all of its associated descriptors are closed. A pipe whose read or write end has been closed is considered widowed. Writing on such a pipe causes the writing process to receive a SIGPIPE signal. Widowing a pipe is the only way to deliver end-of-file to a reader: after the reader consumes any buffered data, reading a widowed pipe returns a zero count. The generation of the SIGPIPE signal can be suppressed using the F_SETNOSIGPIPE fcntl command. RETURN VALUES
On successful creation of the pipe, zero is returned. Otherwise, a value of -1 is returned and the variable errno set to indicate the error. ERRORS
The pipe() call will fail if: [EFAULT] The fildes buffer is in an invalid area of the process's address space. [EMFILE] Too many descriptors are active. [ENFILE] The system file table is full. SEE ALSO
sh(1), fork(2), read(2), socketpair(2), fcntl(2), write(2) HISTORY
A pipe() function call appeared in Version 6 AT&T UNIX. 4th Berkeley Distribution February 17, 2011 4th Berkeley Distribution
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy