![]() |
| | #1 |
| Registered User Join Date: Oct 2009
Posts: 46
| wts wrong in namepipe program Code:
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
int i,j;
char s[]="namedpipe",b[20];
i=mkfifo("namedpipe",0666);
j=open("namedpipe",O_RDWR);
write(j,s,4);
read(j,b,4);
printf("%s\n",b);
return 0;
}
|
| nkrao123@gmail. is offline | |
| | #2 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,381
| Opening a pipe in "read-write" mode is not reliable (nor defined by POSIX, if I remember). You need to actually open the pipe twice, once in O_RDONLY mode and once in O_WRONLY mode. Also, your printf() string is not properly null-terminated.
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is offline | |
| | #3 |
| Registered User Join Date: Oct 2009
Posts: 46
| Thanks for your suggestions |
| nkrao123@gmail. is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| c program that accepts and executes commands? | Cimposter | C Programming | 3 | 09-30-2009 02:58 PM |
| g++ compiler errors with vector class after installing/uninstalling libstlport | Gatemaze | C++ Programming | 2 | 09-16-2009 06:00 AM |
| What is wrong with my code? My first program...... | coreyt1111 | C++ Programming | 11 | 11-14-2006 02:03 PM |
| Calendar Program. What am I doing wrong? | Sektor | C++ Programming | 3 | 01-17-2004 11:39 PM |
| command line program, something wrong in the argv | Unregistered | C Programming | 1 | 09-26-2001 09:36 AM |