1

How to programatically distinguish between system process and the process launched by the user(for example,game process)?

timestee
  • 1,086
  • 12
  • 36

1 Answers1

0

I have to solve a similar problem and am getting the process list in basically the same way as here: Can I use `sysctl` to retrieve a process list with the user?. I am getting the current user ID by finding the process that matches my current app name, and then throwing out all the processes that have a different user ID. That seems to get rid of about 1/2 of the system processes.

Throwing out any process with a pid less than 100 seems to get rid of nearly all the other system processes, and what I'm left with looks pretty good. There are still a few system processes left, and I think I'm going to just ignore them by name. (Though I'm not sure if they are only there because I'm debugging on my phone.)

Community
  • 1
  • 1
Bedevere
  • 47
  • 4