Sponsored Content
Full Discussion: IPC using named pipe
Top Forums UNIX for Advanced & Expert Users IPC using named pipe Post 99194 by sharanbr on Wednesday 15th of February 2006 11:27:24 AM
Old 02-15-2006
IPC using named pipe

Hi All,

I am facing a vague issue while trying to make two process talk to each
other using named pipe.

read process
=========
The process which reads, basically creates FIFO using
mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666)Smilie func.

It then opens the pipe using open func - fd = open (HALF_DUPLEX,O_RDONLY);

After this read function is called - numread = read(fd, test_data, MAX_BUF_SIZE);

Write process
==========
This opens pipe fd = open(HALF_DUPLEX, O_WRONLY);

Then write is done to the pipe - write (fd, 1, 1);

I am finding that even though i am writing a value of 1, it gets
reflected as 255 by read process.

One thing I noticed is that the file descriptor returned for read process
and write process are both different as can be seen by the
program output below

read process - @ 0 NS Created pipe successfully fd = 6
read process - Read fd = 6

write process - Opened pipe for writing only .. fd = 3
write process - New request with data rqst = 1 fd = 3

read process - Received data from test .. ff

Could you please help ..
 

10 More Discussions You Might Find Interesting

1. Programming

IPC using named pipe

Hi All, I am facing a vague issue while trying to make two process talk to each other using named pipe. read process ========= The process which reads, basically creates FIFO using mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666) func. It then opens the pipe using open func - fd = open... (2 Replies)
Discussion started by: sharanbr
2 Replies

2. 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

3. UNIX for Dummies Questions & Answers

Named Pipe contents to a file

I want to copy the contents of a named pipe to a file. I have tried using: cat pipe.p >> transcript.log but I have been unsuccessful, any ideas? (4 Replies)
Discussion started by: carl_vieyra
4 Replies

4. Programming

IPC with PIPE

Hi guys, I'm new to Linux and Unix I have just simple code . But I don't know why it doesn't work .. But, the outputfile is Blank.. I don't understand why.. Please help me.. Thank you very much P.S: sorry, I don't know how to edit this post clearly.. it's hard to read.. Please try.. (2 Replies)
Discussion started by: thanh_sam_khac
2 Replies

5. Shell Programming and Scripting

pipe to file named with date

I would like to pipe (redirect ? - what is the right term?) the output of my script to a file named with the current date. If I run this at a command prompt: date +'%Y%m%d" ...it returns "20110429" OK, that's good... so I try: ./script.sh > "'date +%Y%m%d'.csv" I get a file... (1 Reply)
Discussion started by: landog
1 Replies

6. Shell Programming and Scripting

Using Named pipe in shell script

Hi, I want to use a Named pipe to get input from a growing file for further processing. When I prototype this scenario using a while loop, the data is not written to the named pipe. This the script I use to get data into the Named pipe: #!/bin/ksh mkfifo pipe while (( n <= 10 )) do echo... (2 Replies)
Discussion started by: sudvishw
2 Replies

7. Shell Programming and Scripting

Named pipe performance

Hi, I am getting data into a Named pipe. Does Named pipe have any size restriction; I know it does not have any storage and it just passes on the data to the next process. I want to know, if there will be a difference in the Named pipe performance if the data input is more. (I am using DB2... (1 Reply)
Discussion started by: sudvishw
1 Replies

8. Programming

Problems with pipe IPC

I'm currently studying IPC, I have a first program A: Do an exec for B and wait B: Receive through a fifo a string from a third program "C" and have to resend it to A I was thinking to open a pipe in A before the exec, then passing fd to B as an argument if(pipe(fd)==-1){ ... (1 Reply)
Discussion started by: cifz
1 Replies

9. Programming

Named pipe behavior in Linux

Hi All ! I try to collect importent events from syslog and in my syslog conf, there is something like this: *.* |/logs/ipes/SLpipe1 I have a program, which opens this pipe and reads the messages from it. But how this pipe works ? Where can I probably read something about the details,... (3 Replies)
Discussion started by: mabra
3 Replies

10. UNIX for Dummies Questions & Answers

Named pipe hanging?

Ok, I can't seem to figure this out or find anything on the web about this. I'm on Sun Solaris, UNIX. I have the following test script: #!/bin/ksh touch test.file LOG=./tmp.log rm -f ${LOG} PIPE=./tmp.pipe mkfifo ${PIPE} trap "rm -f ${PIPE}" EXIT tee -a ${LOG} < ${PIPE} & ... (17 Replies)
Discussion started by: Ditto
17 Replies
MKFIFO(3)						     Linux Programmer's Manual							 MKFIFO(3)

NAME
mkfifo - make a FIFO special file (a named pipe) SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int mkfifo(const char *pathname, mode_t mode); DESCRIPTION
mkfifo() makes a FIFO special file with name pathname. mode specifies the FIFO's permissions. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). A FIFO special file is similar to a pipe, except that it is created in a different way. Instead of being an anonymous communications chan- nel, a FIFO special file is entered into the file system by calling mkfifo(). Once you have created a FIFO special file in this way, any process can open it for reading or writing, in the same way as an ordinary file. However, it has to be open at both ends simultaneously before you can proceed to do any input or output operations on it. Opening a FIFO for reading normally blocks until some other process opens the same FIFO for writing, and vice versa. See fifo(7) for nonblocking handling of FIFO special files. RETURN VALUE
On success mkfifo() returns 0. In the case of an error, -1 is returned (in which case, errno is set appropriately). ERRORS
EACCES One of the directories in pathname did not allow search (execute) permission. EEXIST pathname already exists. This includes the case where pathname is a symbolic link, dangling or not. ENAMETOOLONG Either the total length of pathname is greater than PATH_MAX, or an individual filename component has a length greater than NAME_MAX. In the GNU system, there is no imposed limit on overall filename length, but some file systems may place limits on the length of a component. ENOENT A directory component in pathname does not exist or is a dangling symbolic link. ENOSPC The directory or file system has no room for the new file. ENOTDIR A component used as a directory in pathname is not, in fact, a directory. EROFS pathname refers to a read-only file system. CONFORMING TO
POSIX.1-2001. SEE ALSO
mkfifo(1), close(2), open(2), read(2), stat(2), umask(2), write(2), mkfifoat(3), fifo(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-06-12 MKFIFO(3)
All times are GMT -4. The time now is 08:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy