Mike Pateras
Mike Pateras

Reputation: 15015

Tracking Chrome and its many processes

I'm trying to keep an eye on how long an application runs. To do this, I capture every process's ID as it starts, and when that process is shut down, I log the time. However, Google's Chrome starts and stops like 6 processes when you start it up and shut it down, meaning each execution of Chrome gets logged multiple times.

Is there a better way to track the execution of an application than by process ID? Or is there, perhaps, a technique for getting around this particular problem? I'd considered not adding a process ID if a process with the same ID was added within a second or so, but that seems exploitable.

Any ideas?

Upvotes: 2

Views: 200

Answers (2)

Mike Pateras
Mike Pateras

Reputation: 15015

I ended up just checking if I was adding a duplicate. Not very efficient, but easy and effective. It will serve for now.

Upvotes: 0

Toymakerii
Toymakerii

Reputation: 1540

I am not 100% but I would assume that one process in Chrome must be the parent. try eliminating processes from your list if their parent (PPID) is the same (and not init = PID 1)

Upvotes: 1

Related Questions