tags:

views:

51

answers:

2

Hi,

Assume I have an executable called 'exe' which spawns a child process. This child process needs to become a daemon and we need to change its name. Next I want to use killall to send a signal to this process using the new name, but I need to use the old name.

The order of events is as follows:

  1. start 'exec'
  2. fork -> exit if parent
  3. detach (chdir, setsid, umask)
  4. execvp('exec', 'daemon', ...)

On 4, argv[0] is set to 'daemon'.

After this, I can do a 'ps' and a 'top' and I neatly see the name 'daemon' appearing in the output of these commands. However, when I try to kill the process (send a signal to it) using killall, I have to provide the name 'exec' and not 'daemon'.

It seems as if the kernel is not fully aware of the new name.

The reason why I need this functionality is that I want to spawn a few child process with different responsibilities using the same executable. I also want to to be able to stop and start them individually by referring to them by name. And I don't want to symlink the new names to the common exec executable (like busybox does).

Is there a way around this?

I'm using Linux Ubuntu 9.10.

Cheers, Johan

+2  A: 

Some tools use the binary name, others use the process name (what you pass as execvp first argument). Try to cope with it :)

Tronic
Ok, now I know there is a difference between the process name and the binary name.
Johan
+2  A: 

try using pkill instead of killall

nos