Comment 15 for bug 599185

Revision history for this message
Nick Lib (nikolauslieb) wrote :

Thank you for your insight and your suggested fix, edemeulle. I have run into this bug myself and it can be rather annoying.

I have some experience with python, although I know little about /proc and what kinds of things the "cmdline" entry for a process might possibly contain in general. I was just thinking that it would be possible that (in the future) camera monitor might commonly be started with some arguments and thus it may break your suggested fix (as the arguments will be included in "/proc/pid/cmdline" and thus the string would no longer end with "cameramonitor").

If my mild concern is justified, then (afaik) it would be better to check the "comm" entry in proc, rather than "cmdline".

Also, I would guess that fd should by closed, after use, so perhaps an overall slightly better version of this fix would be:

# Check if the process with pid is running
def pid_running(pid):
      if os.path.isdir('/proc/'+pid):
            with open('/proc/'+pid+'/cmdline') as fd:
                  cmd = fd.read()
                  return cmd.strip() == 'cameramonitor'
      else:
            return False

I hope this helps!