System() doesnt give me the control back ..
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > System() doesnt give me the control back ..




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    System() doesnt give me the control back ..  
Vaddina Prakash Rao


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 02:21 AM

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





[ Post a follow-up to this message ]



    Re: System() doesnt give me the control back ..  
Lev Walkin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 02:21 AM

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





[ Post a follow-up to this message ]



    Re: System() doesnt give me the control back ..  
Vaddina Prakash Rao


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-23-04 02:22 AM

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 */
> }





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:46 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register