Ask a Question related to UNIX Programming, Design and Development.
-
Vikas Vijay #1
child processes
hello all,
I am working on Sparc OS version 5.8. I have a code which is sth like
while(i < N)
{
...
do some processing in c++ to create file abc
system("simulator_name < abc")
.....c++ ... processing......
}
The problem is my simulator takes some time T to load and only then
starts working on the file abc.After completion the simulator is
exited and the same thing(loading + execution happens in next
iterations..) Since the number of iterations are huge (wasted time NT)
i want something like :
open the simulator only once( just doing system("simulator_name") and
get the handle to the simulator prompt. From then on i just load the
new "abc" file in each iteration, wait for the simulation to complete
(do not exit the simulator) and start my new iteration.
I read about creating a new child process(popen command) etc but could
not figure out exactly how to get a handle to the prompt, and wait
till the simulation is completed. Also the child process is not to be
killed otherwise i lose the handle.
I would appreciate any help/references in this regard. There is
nothing simulator specific. You can imagine a simple gdb command in
place of simulator_command and handle at gdb>
-Thanks
Vikas
Vikas Vijay Guest
-
Parent/Child relations - Trying to access child control for save
I have a parent datagrid that has my customer information. For each customer I have a child datagrid with all their part information. In the... -
Placeholder child of child control event problem.
Hi, I have problem with placeholder which contain web user control. I want to add user control in placeholder. For example I have a.aspx and in... -
Timing several processes
Hi all! I'm wanting to write a simple web-based tool to see the status of several servers at a glance. I know there are many solutions... -
Limiting child processes in a sub-shell
I'm just wondering if there is a better way to limit the number of processes, lets say gzip processes, to a set limit so that you can achieve... -
Managing linked list through child processes
In article <bO_La.287$W51.134@reader1.news.jippii.net>, Geeco <katjaso76@hotmail.com> wrote: Learn about "shared memory". -- Barry Margolin,... -
Ralf Fassel #2
Re: child processes
* [email]vijayv@ececs.uc.edu[/email] (Vikas Vijay)
| I read about creating a new child process(popen command) etc but
| could not figure out exactly how to get a handle to the prompt, and
| wait till the simulation is completed.
popen() returns a FILE*, which you can use in an fprintf()/fwrite()
call. It is connected to the stdin of the popen'ed() process. So the
solution would be to make your process read commands from stdin (which
it presumably already does when it prompts), process them and read the
next command.
If you need feedback when the processing is finished, you might use
some statefile which the parent creates and the simulator removes to
indicate finish (eg, the `abc' file in your example).
popen() is unidirectional (read/write only), so if you need something
more sophisticated, you need to check the IPC features of your OS
(pipes, shared memory).
R'
Ralf Fassel Guest
-
nal #3
Re: child processes
"Vikas Vijay" <vijayv@ececs.uc.edu> wrote in message
news:ce59d7c6.0307200656.13a98c31@posting.google.c om...------start the simulator here and open a pipe to its standatad input.> hello all,
> I am working on Sparc OS version 5.8. I have a code which is sth like
>------send the files contents to the pipe> while(i < N)
> {
> ...
> do some processing in c++ to create file abc
------// note 'if this code worked, your simulator exits each time it
reads ------a file. so you need to change it to continue receiving file
names and ------may be an exit command in the end.------exit the simulator> system("simulator_name < abc")
> .....c++ ... processing......
> }> The problem is my simulator takes some time T to load and only then
> starts working on the file abc.After completion the simulator is
> exited and the same thing(loading + execution happens in next
> iterations..) Since the number of iterations are huge (wasted time NT)
> i want something like :
>
> open the simulator only once( just doing system("simulator_name") and
> get the handle to the simulator prompt. From then on i just load the
> new "abc" file in each iteration, wait for the simulation to complete
> (do not exit the simulator) and start my new iteration.
>
> I read about creating a new child process(popen command) etc but could
> not figure out exactly how to get a handle to the prompt, and wait
> till the simulation is completed. Also the child process is not to be
> killed otherwise i lose the handle.
> I would appreciate any help/references in this regard. There is
> nothing simulator specific. You can imagine a simple gdb command in
> place of simulator_command and handle at gdb>
>
> -Thanks
> Vikas
nal Guest



Reply With Quote

