|
Home > Archive > Unix Programming > September 2004 > System() doesnt give me the control back ..
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
System() doesnt give me the control back ..
|
|
| Vaddina Prakash Rao 2004-09-22, 9:21 pm |
| Hello every one,
In our Linux Encoding system, a copy of helix dna producer is running
.....
i wrote an applicatoin which can remotely communicate with the
encoding machine ... Its function include
1. Kill currently running copy of the producer and
2. Restart the producer with new settings.
killing part of the producer was quite easy. But restarting it is
where i face problems. I use the system() function to issue the
command. But the problem is helix producer doesnt give back the
control to my program which makes my program not to respond. Does any
one have an idea for this ?? And can anyone suggest where does
function like fork, exec fit in my program ...
thanking you,
Vaddina Prakash Rao
| |
| Lev Walkin 2004-09-22, 9:21 pm |
| Vaddina Prakash Rao wrote:
> Hello every one,
> In our Linux Encoding system, a copy of helix dna producer is running
> ....
> i wrote an applicatoin which can remotely communicate with the
> encoding machine ... Its function include
>
> 1. Kill currently running copy of the producer and
> 2. Restart the producer with new settings.
>
> killing part of the producer was quite easy. But restarting it is
> where i face problems. I use the system() function to issue the
> command. But the problem is helix producer doesnt give back the
> control to my program which makes my program not to respond. Does any
> one have an idea for this ?? And can anyone suggest where does
> function like fork, exec fit in my program ...
Pseudocode:
int
run_in_background(const char *progname) {
pid_t child_pid;
/*
* Fork-off another process.
*/
child_pid = fork();
switch(child_pid) {
case -1:
return -1; /* error creating a process */
default:
/* Forked off child successfully */
return 0;
case 0:
break;
}
/*
* This code will be executed only in child.
*/
execlp(progname, profname, (char *)0);
_exit(127); /* Could not start program */
}
--
Lev Walkin
vlm@lionet.info
| |
| Vaddina Prakash Rao 2004-09-22, 9:22 pm |
| Hi
thanks for the reply ,,
I found a workaround and thought this could be useful to someone ,, So
here is what i did
just use the command "start-stop-daemon -S -b -x
<path-of-the-executable> -- <Application-settings>"
Examlple: start-stop-daemon -S -b -x /helix/producer/producer -- -vc
/dev/video0 -vp 1 -vco rv9 -sp PASSWORD@10.10.10.97:30001/stream01 -ad
256k -cs 192x144 -vf 0
-dt -da -pid /prod.pid
-S option is to start
-K if you want to stop
-b To push into the background
-x monitors if any copy of the executable is running, and starts a new
one only if a copy of the process is not running.
Its definitely an easy implementation ,,
prakash
Lev Walkin <vlm@lionet.info> wrote in message news:<2qvj4kF14o9l0U1@uni-berlin.de>...
> Vaddina Prakash Rao wrote:
>
>
> Pseudocode:
>
> int
> run_in_background(const char *progname) {
> pid_t child_pid;
>
> /*
> * Fork-off another process.
> */
> child_pid = fork();
> switch(child_pid) {
> case -1:
> return -1; /* error creating a process */
> default:
> /* Forked off child successfully */
> return 0;
> case 0:
> break;
> }
>
> /*
> * This code will be executed only in child.
> */
> execlp(progname, profname, (char *)0);
> _exit(127); /* Could not start program */
> }
|
|
|
|
|