The daemon function should not kill processes based on the name of the process. The problem with this is that when starting a daemon with the same name but different parameters (in my case httpd), it does not function properly. The daemon function will kill the first process it finds of that name, which may or may not be the right one. Instead of killing by process name, it would be better to use pids or even the whole command line, not just the process name.
- first of all, I'm assuming you mean killproc(). daemon() doesn't kill anything. - killproc() uses pidofproc, which first checks pid files, and then ps, etc. What are you trying to do that you need to specify some but not all processes?- first of all, I'm assuming you mean killproc(). daemon() doesn't kill anything. - killproc() uses pidofproc, which first checks pid files, and then ps, etc. What are you trying to do that you need to specify some but not all processes?
Okay, I filled it out without rechecking what was going on. The problem I'm running into is with daemon not starting a process of the same name. I'm doing a project with 2 web server configurations and if I use daemon, it returns imediately without launching the second web server. I save the pid of the second webserver to a different file name (ie. httpd.internal.pid). So the pidofproc() function will eventually use ps to get the pid of the first webserver and daemon will not launch the second. The way debian does their start-stop-daemon script is they allow you to specify a pidfile for the daemon you are going to be starting. This isn't a huge deal for us because we can just start httpd however we want. We just wanted to do things the way Redhat does them because we are creating an add-on to Redhat. The ability to specify a pidfile would be a nice feature.