pipe « fork « C Q&A

Home
C Q&A
1.assembly
2.buffer
3.Card
4.Cast
5.compile
6.console
7.const
8.constructor
9.database
10.Date
11.Debug
12.Design
13.Development
14.DLL
15.encrypt
16.enum
17.eof
18.Event
19.fork
20.Format
21.gcc
22.gdb
23.graph
24.graphics
25.gui
26.Holiday Event
27.image
28.IP
29.iterator
30.macro
31.makefile
32.malloc
33.Menu
34.mysql
35.network
36.openssl
37.operator
38.password
39.pipe
40.preprocessor
41.printf
42.pthread
43.Regular expression
44.scanf
45.semaphore
46.SerialPort
47.server
48.Socket
49.sql
50.SQLserver
51.sscanf
52.std
53.stdin
54.stdout
55.stl
56.strcmp
57.stream
58.switch
59.Template
60.thread
61.timer
62.unix
63.video
64.Virtual
65.visualstudio
66.winapi
67.windows
68.xml
C Q&A » fork » pipe 

1. fork() and pipe()    stackoverflow.com

I need help with this sample application. When I run it, it gets stuck after the child process prints "Child sending!".

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>

#define INPUT 0
#define OUTPUT 1
int main()
{
 ...

2. Lost in Multiple Fork(), Pipe() and Select()    stackoverflow.com

Hope I can find some help here cause I'm starting to give up. Heads up as this is an homework assignment, hence why it might be stupid. Context: Have to program something which ...

3. Having trouble with pipes and select()    stackoverflow.com

I seem to be having trouble with pipe and select. Context: Have to program something which will be shell executed as such:
logn [--tick n] cmd [args] [, cmd [args]]... Basically, it's ...

4. Can popen() make bidirectional pipes like pipe() + fork()?    stackoverflow.com

I'm implementing piping on a simulated file system in C++ (with mostly C). It needs to run commands in the host shell but perform the piping itself on the simulated ...

5. fgetc blocking : problem with reading from a pipe    stackoverflow.com

I want to be able to fork a process and have the child and parent have a bi-directional link using pipes. I create 2 pipes and make parent read from the ...

6. multiple processes via socketpair hang sometimes    stackoverflow.com

I am trying to implement something that will give me a solution for:

       | --> cmd3 --> cmd4 -->
cmd2-->|
       ...

7. Reading and writing data through a pipe    stackoverflow.com

I have created two processes using fork(). The child process is producing and writing continuously a variable amount of data (array char) to the pipe. The parent process reads from the ...

8. C: dup2, pipe and fork not working as expected    stackoverflow.com

I'm trying to do a simple fork -> execute another program -> say "hello" to that child process -> read back something -> print what received. The program used as child just ...

9. Strategy for bail out when dealing with pipes, fork    stackoverflow.com

I wrote a little program using fork to create new processes which use pipes to communicate. Applying defensive programming, I check every return value. If a return value indicates that something ...

10. Iterative Fork() and Pipes in C    cboard.cprogramming.com

Hello all, Hope you are all doing well. I am very new to c programming and I have a task where I must make three (or more forks) communicate with the process that created them. I used a for loop to create the forks, which did fine. However, when trying to communicate, I used pipes (on the basis of FIFO), but ...

11. help with pipes/fork    cboard.cprogramming.com

12. Using pipe and fork to form a ring    cboard.cprogramming.com

#include #include #include #include #define MAX 512 void make_trivial_ring(){ int fd[2]; pipe (fd); dup2(fd[0], STDIN_FILENO); dup2(fd[1], STDOUT_FILENO); close(fd[0]); close(fd[1]); } void add_new_node(int *pid){ int fd[2]; pipe (fd); *pid = fork(); if (*pid > 0) dup2(fd[1], STDOUT_FILENO); else dup2(fd[0], STDIN_FILENO); close(fd[0]); close(fd[1]); } int main(int argc, char *argv[ ]) { int k, i, childpid; int maxpid, maxnode, maxnum; ...

13. Program using Fork and Pipe    cboard.cprogramming.com

Hi, Can anyone help me with my assignment? "Write a program in C which creates a child (with the use of fork) and between the child and the parent there is bidirectional communication through the use of pipes. The child process will read letters from the user (keyboard) and it will send them to the father. If the father process finds ...

14. fork + pipe + dup2    cboard.cprogramming.com

Hi, I'm developing a simple shell in C but I'm experiencing some problems to execute pipe separated commands properly, such as: 'env | sort' and others which make usage of the pipe '|'. As you may know, the pipe is the redirection of the stdout of the first command to the stdin of the second command. Therefore, in my program, when ...

15. crazy pipe/fork    cboard.cprogramming.com

crazy pipe/fork hi i have a problem with either my forking or pipe which i cant spot or get my head around . Right here is my fork code: right what this is supposed to do is when I run the program "./spool 3" for instance it is meant to make 3 child processes and put them on the fifo pipe ...

16. Fork - Pipe trouble    cboard.cprogramming.com

marktee() { pid_t pid; int i; int pi[2]; int fi[2]; int status; pipe(pi); pipe(fi); for(i=0; i<2 && (pid=fork()); i++); if(i==0 && pid==0) { printf("Child 1\n"); close(fi[0]); dup2(pi[1],1); close(pi[1]); execlp("/usr/bin/tee","tee","t1.txt",0); } if(i==1 && pid==0) { printf("Child 2 \n"); //close(pi[1]); close(fi[0]); dup2(pi[0],0); dup2(fi[1],1); close(fi[1]); execlp("/usr/bin/tee","tee","t2.txt",0); } else { printf("Parent\n"); close(pi[0]); close(pi[1]); close(fi[1]); dup2(fi[0],0); execl("/usr/bin/tee","tee","t3.txt",0); wait(&status); }

17. fork() and pipe()    cboard.cprogramming.com

You can't. IIRC, each write() is atomic. So if you prepare what you want to write in a buffer, then use a single write() call to write it, then that data will be read at the other end of the pipe as a contiguous block (that is, not mixed up with anyone elses write calls).

18. fork and pipe    cboard.cprogramming.com

19. Iterative Fork() and Pipes in C    forums.devshed.com

Hello all, Hope you are all doing well. I am very new to c programming and I have a task where I must make three (or more forks) communicate with the process that created them. I used a for loop to create the forks, which did fine. However, when trying to communicate, I used pipes (on the basis of FIFO), but ...

20. Checking if stderr is active when using pipe() and fork()?    forums.devshed.com

Hi Everyone, I'm (yet again) having some problems, I've successfully got a parent and child to talk to one another using fork() and pipe(). I have also closed off stdin, stdout and stderr and now send them over to the parent, where they will be logged. What I want to do is check if the stderr pipe is active (i.e. that ...

21. Fork() and pipe()    forums.devshed.com

You're creating the pipe after the fork. Both the child and the parent are creating their own pipes rather than sharing a single pipe. Also, your code would be a lot more legible if cleaned up those if statements. If you get an error condition, just return from the function or use separate ifs for each condition. This makes it obvious ...

22. Multiple fork, pipes???    forums.devshed.com

What this code does is, parent process forks a child and then child forks a child. Parent writes a string to the pipe, child reads it and then writes it to the next pipe, the one connecting child and child's child. Child's child reads it and prints it in stdout Code: #define BSIZ 20 int fdpipe[2][2]; int main(){ pipe(fdpipe[0]); if(fork()!=0){//parent close(fdpipe[0][0]); ...

23. help needed with pipe & fork()    daniweb.com

#include #include #include #include #include #include #include #include #include #define SIZE 60 int main (int argc, char* argv[]){ int fdfork, fdfile,fdf; int pfd[argc - 3][2]; char temp_arr[SIZE]; int i,k,j; //in order to create son processes and pipe matrix for all son for(i = 0 ; i < argc-3 ; i++){ if(pipe(pfd[i]) == ...

24. Use sys calls fork(),pipe(),open() .....    daniweb.com

hi.......We have a task to write a program in C in linux environment that takes 2 command line arguments: 1.the name of a text file that contains single-digit integer data in one line 2.an integer to be searched from the sorted version of data in file. The prgram creates a child process that reads the text file paased as the first ...

25. Pipe/Fork in C (win32)    codeproject.com

You are welcome. What do you mean? Threads are called threads in all systems I know, including POSIX-based. When I started to work with Linux, there were only processes; and threads were introduced later. Old processed could be understood like newer single-thread-only process. The units of execution are always threads; processes just host one ore more thread and provide complete data ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.