• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

using the system function

When using the system function is there
a way not to completely exit the
program when the call is made. I want program control to be returned to the next line of the function in which the system call was made.

0
admiral
Asked:
admiral
  • 3
1 Solution
 
jhurstCommented:
As you ask the question, that is exactly what does happen.  The system() creates a new process that does the requested operation and waits for it to complete and then when the function is complete the statement following the system() is executed.
0
 
jhurstCommented:
If what you really mean is that you want to continue while the system() invoked thing processes, then do system("your request &"); assuming that we are taliking unix/linux here.

The & causes the function to be invoked as a background task, and the directly invoked process will exit and return control to you.
0
 
ozoCommented:
Or you might do an explicit fork yourself. (if that's what you really mean)
0
 
jhurstCommented:
fork would be better.  My method essentially does a fork() but by using the shell to do it for you.  I allowed myself to be misled by the request wording.  The only thing that I do not like about fork compared to my method is that on some web servers there will then be two perl interpretters running when one was created only to run the non-perlcommand, whatever it is,  And, you need to understand a little more about process ids to understand what is going on in a fork.
0
 
admiralAuthor Commented:
Thanks for all your help !
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now