parent not waiting until child complete executing another program through execl()
Hi,
I am calling a program that greps and returns 72536 bytes of data on STDOUT, say about 7000 lines of data on STDOUT.
I use pipe from the program am calling the above program. Naturally, I execute the above program (through execl() ) throught the child process and try to read the STDOUT data through parent process by doing dup2(inpipe[1], STDOUT_FILENO) on child and doing read(inpipe[0], line, 10000), line = char[10000];
I am unable to read all 7000 lines of data from STDOUT into the character array. If I run it straight, only around 450 lines of data is obtained. Then, if I put a sleep(5) function / getchar() in the parent process, the number of lines that I read increases to 900 and 1300. waitpid() is not helping me here. This seems to be some memory problem, but there is no problem with the size of the char array.
Following is the program:
The executable program that prodoces 7000 lines (dfs-zgrep.cc) is:
The program (check_pipes.cc) from which am calling the above binary is:
How do I read all the data and pass it to STDOUT (through cout) without losing data?
Thanks for the help gautham... yes, if I execute the read statement one more time with the same pipe and another char array, I am able to read the next set of buffered output in the pipe. Which means that consecutive read()s does help in displaying complete output.
I am just thinking of framing a correct while / for loop for this. Let me know if something crosses your mind - a while / for loop for doing COMPLETE read().
Here is my test code
process = sp.Popen( + ,
bufsize=1,
universal_newlines=True,
stdout=sp.PIPE, stderr=sp.STDOUT,
cwd=src_home)
output, _ =... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
"Your a7.c program should use printf to print a nice message. (You can decide what to say.) Then the process... (9 Replies)
Hi,
I need to initiate a process script which will start and do some processing and then shuts down. Then i need to other verifications. But the the process takes around 25 to 3o minutes.
One thing i can monitor the nohup.out file for this process where i can wait for shutting down statement to... (3 Replies)
I'm not sure if this is the right place to post this issue...but here goes...
I am converting a set of windows jobs from Control-M to AutoSys r11.3. The same command line is being executed in both systems. The Control-M job runs to compltion in about 1.5 hours, waiting for the entire batch... (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)
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)
Received the Timed out message consistently when I tried to jumpstart an M5000 with:
boot jsnet:speed=1000,duplex=full - install
Made the error go away by adding link-clock parameter:
boot jsnet:speed=1000,duplex=full,link-clock=master - install
"link-clock=master" disables... (1 Reply)
Hi,
I haev to devlop a script which when executed will take in a sudo privelege and run a set of commands then will go back to parent shell and execute the rest of the command
But the problem I am facing is that when the script is executed it takes the sudo privelege but it waits for the... (0 Replies)
Hi,
Am new to Linux internals.
I want to use shared memory segment between the parent and the child processess.
if i create a shared memory before fork,the child inherits the attached
shared memory segments but once i call exec in the child process, all attached shared memory segments... (1 Reply)
I don't follow what these are...
this is what my text says...
"When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)