Codebase list debian-goodies / 1a2fa35
Read /proc/<pid>/cmdline just in the case of the executable command (/proc/<pid>/exe) is linked to an interpreter. The regex only looks for Perl and Python based daemons. With this, the command passed to "dpkg-search --search" successfully find the initscript used to restart the daemon. See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=657087 Javier Fernandez-Sanguino 11 years ago
1 changed file(s) with 12 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
525525
526526 try:
527527 self.program = os.readlink('/proc/%d/exe' % self.pid)
528 # if the executable command is an interpreter such as perl/python,
529 # we want to find the real program
530 m = re.match("^/usr/bin/(perl|python)$", self.program)
531 if m:
532 with open('/proc/%d/cmdline' % self.pid, 'r') as cmdline:
533 # only match program in /usr (ex.: /usr/sbin/smokeping)
534 # ignore child, etc.
535 #m = re.search(r'^(([/]\w*){1,5})\s.*$', cmdline.read())
536 m = re.search(r'^(/usr/\S+)$', cmdline.read())
537 if m:
538 # store the real full path of script as the program
539 self.program = m.group(1)
528540 except OSError, e:
529541 if e.errno != errno.ENOENT:
530542 if self.pid == 1: