It can take bytes partially but I have no idea if that's the case right now because
a) You haven't posted enough of the program
b) You haven't checked read's return value
c) You're feeding the array into printf("%s") which expects strings, even though
c) read doesn't read strings! It puts no null terminator in it for you! Use write or fwrite!
Till now i was considering that pipes and fifo are same except the fact that fifo's existence can be control since it has a name and sometimes resides in a file system.
But now i have doubt, is there any other difference between them considering implementation and usage.
This is what i was referring to
Quote:
A pipe is a mechanism for interprocess communication; data written to the pipe by one process can be read by another process. The data is handled in a first-in, first-out (FIFO) order. The pipe has no name; it is created for one use and both ends must be inherited from the single process which created the pipe.
A FIFO special file is similar to a pipe, but instead of being an anonymous, temporary connection, a FIFO has a name or names like any other file. Processes open the FIFO by name in order to communicate through it.
Ok i ll send you everything in case you understand what is hhappening. I do everything as i saw it online.I keep getting an Input/Output error on read.
I repeat: fifo's might not work on Windows, because windows doesn't even have them. The closest it has is a named pipe that doesn't actually exist as a file anywhere.
Quote:
if (mkfifo(myfifo, 0666) != 0)
perror("mkfifo() error");
You don't actually quit after most errors.
Unless you really want to view everything as one giant messy line, you might want to put an \n in things once in a while.
Can't forget that. If b.exe fails to run for any reason, the child will keep going!
That extra semicolon means it will always print 'write error', even when there's no write error.
Why is the parent opening the fifo twice? The child doesn't open it twice, the parent will wait forever for something to open it again.
Why do you have your child code in a separate program when you could put it all in one and save yourself a lot of headaches?
0 is not null, 0 is 0. Try '\0'.
...not that you actually need a null terminator any more when you use write(). How about fprintf(stderr, "%d bytes\n", (int)numread); to see how many you actually read?
---------- Post updated at 09:29 AM ---------- Previous update was at 09:19 AM ----------
Lastly: Your main program is writing 0 bytes on purpose because you're checking the length of the wrong buffer -- buf, instead of data.
---------- Post updated at 09:33 AM ---------- Previous update was at 09:29 AM ----------
Also: sizeof(MAX_BUFFER) is probably 4 or 8, not 5000 like you intended. Just MAX_BUFFER is what you want.
---------- Post updated at 09:38 AM ---------- Previous update was at 09:33 AM ----------
Also if(fd = open(myfifo, O_WRONLY)<0) doesn't have enough brackets. fd becomes either 0 or 1 -- which is never the FD of your open fifo! You've been reading from stdin and writing to stdin, not your fifo, I think.
When I correct all that, it works fine, with no sleep().
Hi all,
I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens.
could anyone please tell me how to make parent to wait in child process in shell script?
thanks... (2 Replies)
I have two scripts lets say A.expect and B.sh needs to be executed.
I am executing B.sh from A.expect where B.sh has sleep command.
My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits.
but my A.expect should execute only after completing B.sh.
Is... (3 Replies)
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Hello, everyone.
Here's a program:
pid_t pid = fork();
if (0 == pid) // child process
{
execvp ...;
}
I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process.
However I don't want to child process to receive the... (7 Replies)
1. The problem statement, all variables and given/known data:
I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process.
2. Relevant commands, code, scripts,... (0 Replies)
Hi, i want that the parent process start before the child, this code doesn't work,
if the child start before the parent it wait for signal, then the father send the signal SIGALRM and the child catch it and call printf;
else the father call printf and send the signal to the child that call its... (1 Reply)
Hi All,
I facing a problem in handling signals between parent process communication. I am trying to send a signal(SIGINT) from child to parent. I am using kill function to do so and I am trying to read the signal using sigaction(). But the program is ending abruptly and I am not able to figure out... (4 Replies)
Hi All,
I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program.
I want 1st script to wait until the 'C' program completes.
I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Hi All,
I will be glad if you could help me resolve this problem.
I have created two detachable threads and wanted to them execute independent of the parent thread ( the main task which creates the detachable threads). But I see no output coming from the execution of two detachable threads.... (4 Replies)
Hi
I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running.
My Code:
... (1 Reply)