Get other process' argv in OS X using C

后端 未结 2 1416
醉梦人生
醉梦人生 2020-11-30 11:55

I want to get other process\' argv like ps.

I\'m using Mac OS X 10.4.11 running on Intel or PowerPC.

First, I read code of ps and man kvm, then I wrote some

相关标签:
2条回答
  • 2020-11-30 12:41

    I've actually been needing the same thing for a Python library I'm writing, and in my searching I came across another Python lib (PSI) that implements this in C code. It's part of the python module code for listing processes and includes listing the arguments for each process as well. You could take a look at the source code for that for a working example:

    darwin_process.c - scroll down to set_exe() for the relevant code

    Note: the site is really slow so you'll have to be a bit patient while it loads.

    0 讨论(0)
  • 2020-11-30 12:49

    In 10.6, KERN_PROCARGS2 is available: https://gist.github.com/770696

    This way is used from ps, procfs on MacFUSE, etc.

    0 讨论(0)
提交回复
热议问题