Bug#1033311: sysvinit-utils: pidof not always returning a pid when using the full path to a program

Matthew Vernon matthew at debian.org
Wed Mar 29 08:36:24 BST 2023


On 24/03/2023 14:17, Jesse Smith wrote:

> On 2023-03-24 6:44 a.m., Markus Fischer wrote:
>> I think I've figured it out. With the following patch I don't see the
>> unexpected behaviour anymore:
>>
>> --- a/src/killall5.c
>> +++ b/src/killall5.c
>> @@ -662,6 +662,7 @@ int readproc()
>>                  /* Try to stat the executable. */
>>                  snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
>>                   p->pathname = (char *)xmalloc(PATH_MAX);
>> +               memset(p->pathname, 0, PATH_MAX);
>>                  if (readlink(path, p->pathname, PATH_MAX) == -1) {
>>                          p->pathname = NULL;
>>                  }
>>
> 
> This patch looks good to me. I'm adding it upstream.
> 
> Will run some more tests before publishing 3.07. And would appreciate it
> if everyone following this issue could test too and provide feedback.

Given subsequent discussion, could we instead use canonicalize_file_name 
or realpath here instead? That would give us the "correct" path without 
pidof having to think hard about symlinks et al.

Matthew



More information about the Debian-init-diversity mailing list