Between two binaries, one pipe can serve only one way communication. YOU need two pipes for to and fro communication. You need one pipe to write data to STDIN of another program (B) and need another pipe to read the STDOUT from that another program (B).
Hi,
Program A: uses pipe()
I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:
* child
-> dup2(fd, STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);
* parent
-> char line;
-> read(fd, line, 100);
Question:
---------... (1 Reply)
PROGRAM A <-> PROGRAM B
PROGRAM A sends data as STDIN ro PROGRAM B and when PROGRAM B is executed from PROGRAM A, it sends output back to PROGRAM A. This is implemented using 2 pipes (fd1 & fd2).
The above process happens in a loop and during the second run, the previous data that had been... (10 Replies)
Hi,
Program A: uses pipe()
I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using:
* child
-> dup2(fd, STDOUT_FILENO);
-> execl("/path/PROGRAM B", "PROGRAM B", NULL);
* parent
-> char line;
-> read(fd, line, 100);
Question:
---------... (3 Replies)
Hi all
I've run into a snag in a program of mine where part of what I entered in at the start of run-time, instead of the current value within printf() is being printed out.
After failing with fflush() and setbuf(), I tried the following approach
void BufferFlusher()
{
int in=0;... (9 Replies)
When a process fork(), the child share the same file descriptors as his father. Thus, they share the same stdin. Quick and dirty exemple below (sorry for the ugly gets() call) :
#include <stdio.h>
#include <unistd.h>
int main()
{
char buf;
if (fork()) { /*parent */
... (1 Reply)
hello everybode.Got some sort of "problems" with this stuff;
well this is a program
int main()
{
int Pipe;
int origStdin, origStdout;
int childPID;
origStdin = dup(0);
origStdout = dup(1);
pipe(Pipe);
if( (childPID = fork()) < 0 )
{
perror(... (2 Replies)
Hi,
i am using the below program to read from the standard input or to write to standard out put.
i know that using highlevel functions this can be done better than what i have done here.
i just want to know is there any other method by which i find the exact number of characters ( this... (3 Replies)
Well.. let's say i need to write a pretty simple script.
In my script i have 2 variables which can have value of 0 or 1.
$VERBOSE
$LOG
I need to implement these cases:
($VERBOSE = 0 && $LOG = 0) => ONLY ERROR output (STDERR to console && STDOUT to /dev/null)
($VERBOSE = 1... (5 Replies)
Discussion started by: Marmz
5 Replies
LEARN ABOUT HPUX
pipe
pipe(2) System Calls Manual pipe(2)NAME
pipe() - create an interprocess channel
SYNOPSIS DESCRIPTION
creates an I/O mechanism called a pipe and returns two file descriptors, fildes[0] and fildes[1]. fildes[0] is opened for reading and
fildes[1] is opened for writing.
A read-only file descriptor fildes[0] accesses the data written to fildes[1] on a first-in-first-out (FIFO) basis. For details of the I/O
behavior of pipes see read(2) and write(2).
By default, HP-UX pipes are not STREAMS-based. It is possible to generate the kernel so that all pipes created on a system are STREAMS-
based. This can only be done for HP-UX releases 10.0 and later. STREAMS-based FIFOs (created by or are not supported on HP-UX.
To generate a kernel that supports STREAMS-based pipes:
o STREAMS/UX must be installed.
o The module and the driver must be included in the file. (When STREAMS/UX is installed, and are automatically added to the system
file.)
o The tunable parameter (see streampipes(5)) must be set to 1 in the file. (This is not automatically done when STREAMS/UX is
installed.)
o The kernel must be generated and the system rebooted. Once this is done, all pipes created by will be STREAMS-based.
For more information, see
EXAMPLES
The following example uses to implement the command string
RETURN VALUE
returns one of the following values:
Successful completion.
Failure.
is set to indicate the error.
ERRORS
sets to one of the following error values if the corresponding condition is true.
or more file descriptors are currently open.
The system file table is full.
The file system lacks sufficient space to create the pipe.
Could not allocate resources for both Stream heads
(STREAMS-based pipes only).
SEE ALSO sh(1), read(2), write(2), popen(3S), privileges(5), streampipes(5), streamio(7).
STANDARDS CONFORMANCE pipe(2)