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.
I'm using a daemon which takes requests (fetces rows) from a database and then starts an rsync (remote synchronization tool provided by samba) with the exec() command. I want to add a feature so that the daemon can stop (kill -STOP) an rsync process and then continue later (kill -CONT).
My problem is that after executing the exec command inside the forked-process the pid of the rsync-process is unknown (exec() does not return the pid) so I don't know it's value to stop it later...
Any help appreciated
Thanks for your time & sorry for my bad english
Unless I am sadly mistaken, execreplaces the calling process with the one that you are executing. The call returns only if it does not succeed.
So, if you fork a child process which then execs another program-file, the PID of the child has not changed. It has ceased to be an instance of the original parent-process and has become an instance of the program that it execed.
So your diagram is incorrect. There are never three layers.
PS Do the same thing with stdin if you want to send info TO the process; then you can use 'fgets_unlocked' to check for a signal periodically without freezing the thread waiting for input. http://www.gnu.org/software/libc/man...tml#Line-Input
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.