ProgrammingThis 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.
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.
Hi all,
I need to start a deamon running in my system background before I start up my user code. I was going to run it through a start up script, however thought it might be better to start it up from with in my code. Could anyone advise if this can be done in C.
Thanks
Yes, however, look at all the details of each method (as mentioned above). A fork then exec will allocate a whole new process memory space and executes a copy of your code with that program counter value at the time of the fork. Kind of like a new thread, but a whole new process memory space. If that is what you want, that is the way to go.
Yes, however, look at all the details of each method (as mentioned above). A fork then exec will allocate a whole new process memory space and executes a copy of your code with that program counter value at the time of the fork. Kind of like a new thread, but a whole new process memory space. If that is what you want, that is the way to go.
Ofcourse, a new process space will be allocated as a result of fork and then exec would cause that space to be replaced with the daemon's copy. But that is what he wanted right? run a daemon/background *process*.
A fork then exec will allocate a whole new process memory space and executes a copy of your code with that program counter value at the time of the fork. Kind of like a new thread, but a whole new process memory space. If that is what you want, that is the way to go.
The copy of code will be executed only till the point there is an exec command.
After executing the exec command, the execution of code is in its own.
And the creation of a thread and to that of a process is completely different.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.