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(3C)						   Standard C Library Functions 						mkfifo(3C)

NAME
mkfifo - make a FIFO special file SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int mkfifo(const char *path, mode_t mode); DESCRIPTION
The mkfifo() function creates a new FIFO special file named by the pathname pointed to by path. The file permission bits of the new FIFO are initialized from mode. The file permission bits of the mode argument are modified by the process's file creation mask (see umask(2)). Bits other than the file permission bits in mode are ignored. If path names a symbolic link, mkfifo() fails and sets errno to EEXIST. The FIFO's user ID is set to the process's effective user ID. The FIFO's group ID is set to the group ID of the parent directory or to the effective group ID of the process. The mkfifo() function calls mknod(2) to create the file. Upon successful completion, mkfifo() marks for update the st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The mkfifo() function will fail if: EACCES A component of the path prefix denies search permission, or write permission is denied on the parent directory of the FIFO to be created. EEXIST The named file already exists. ELOOP A loop exists in symbolic links encountered during resolution of the path argument. ENAMETOOLONG The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. ENOENT A component of the path prefix specified by path does not name an existing directory or path is an empty string. ENOSPC The directory that would contain the new file cannot be extended or the file system is out of file-allocation resources. ENOTDIR A component of the path prefix is not a directory. EROFS The named file resides on a read-only file system. The mkfifo() function may fail if: ELOOP Too many symbolic links were encountered in resolving path. ENAMETOOLONG The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. EXAMPLES
Example 1: Create a FIFO File The following example demonstrates how to create a FIFO file named /home/cnd/mod_done with read and write permissions for the owner and read permissions for the group and others. #include sys/types.h> #include sys/stat.h> int status; ... status = mkfifo("/home/cnd/mod_done", S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mkdir(1), chmod(2), exec(2), mknod(2), umask(2), stat.h(3HEAD), ufs(7FS), attributes(5), standards(5) SunOS 5.10 24 Apr 2002 mkfifo(3C)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy