Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-22-2005, 11:57 AM
|
#1
|
LQ Newbie
Registered: Apr 2005
Posts: 26
Rep:
|
I want to start a prog from another prog but not as child
Hi, I need to know if theres a way to start a program from another program without using fork() the thing is i dont want that the new program apears like child of the first one, both programs execute in a console, and the program i want to start has no usr interface (it runs in background), I have already tryed this in my code but didnt work:
sprintf(eHab->cBuffIO, "./Persona %s %hd no", eHab->cIp, eHab->usPuerto);
system(eHab->cBuffIO);
./Persona is the program, and eHab->cIp, eHab->usPuerto are the params
Thanks, Damian.
|
|
|
05-22-2005, 01:40 PM
|
#2
|
Member
Registered: May 2005
Posts: 378
Rep:
|
Use one of the exec(3) family of system calls. man 3 exec for details. Ask here again if you need clarification of what you've read.
|
|
|
05-22-2005, 02:07 PM
|
#3
|
LQ Newbie
Registered: Apr 2005
Posts: 26
Original Poster
Rep:
|
In first place thanks for your help, I know about those functions, cant use them, sry I forgot to say that I need both programs working, the problem is that those functions remplace the program that calls it by the new prog thats being executed, the way to avoid that is using fork() but the new program will apear as a child, and I cant do that.
If you know about any other way to do it, or if thers no posible way, please tell me.
Thanks again Damian.
|
|
|
05-22-2005, 08:14 PM
|
#4
|
Member
Registered: May 2004
Posts: 552
Rep:
|
You must then fork() twice. The first fork starts a second fork and then the first one terminates, causing the process to be owned by init process.
|
|
|
05-23-2005, 05:12 PM
|
#5
|
Member
Registered: May 2005
Posts: 378
Rep:
|
Quote:
the new program will apear as a child, and I cant do that.
|
All processes have a parent process so they all appear to run as a child. Or do you mean it mustn't be owned by the spawning process (in which case randyding's reply is your answer)? Any particular reason - I'm intrigued?
|
|
|
05-23-2005, 05:37 PM
|
#6
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
You could fork() the program, then call daemon(0,0).
After daemon(0,0) the program will not have any terminal to talk to anymore though.
|
|
|
All times are GMT -5. The time now is 12:31 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|