dongle7553 2015-07-09 21:05
浏览 165
已采纳

检查进程是否为Go应用程序(在Linux / Unix中)

I am using ps (specifically the psutil python library) to see a list of running processes on my linux machine. I want to deterimine which processes are running Go applications (that is, they are running Go code).

Below is the ps output for a process that is written in Go. Is there anything that indicates that it is running Go code?

{'cmdline': ['./SampleMePlz'],
 'connections': [connection(fd=3, family=10, type=1, laddr=('::', 8080), raddr=(), status='LISTEN')],
 'cpu_affinity': [0, 1, 2, 3],
 'cpu_percent': 0.0,
 'cpu_times': cputimes(user=0.0, system=0.0),
 'create_time': 1436474176.89,
 'cwd': '/home/ben/gocode/src/SampleMePlz',
 'exe': '/home/ben/gocode/src/SampleMePlz/SampleMePlz',
 'ext_memory_info': meminfo(rss=4071424, vms=192684032, shared=3092480, text=3096576, lib=0, data=179523584, dirty=0),
 'gids': group(real=5000, effective=5000, saved=5000),
 'io_counters': io(read_count=12, write_count=0, read_bytes=4096, write_bytes=0),
 'ionice': ionice(ioclass=0, value=4),
 'memory_info': meminfo(rss=4071424, vms=192684032),
 'memory_maps': [mmap(path='/lib/x86_64-linux-gnu/libpthread-2.15.so', rss=65536, size=2199552, pss=8192, shared_clean=57344, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=65536, anonymous=8192, swap=0),
                 mmap(path='/lib/x86_64-linux-gnu/libc-2.15.so', rss=311296, size=3903488, pss=26624, shared_clean=286720, shared_dirty=0, private_clean=0, private_dirty=24576, referenced=311296, anonymous=24576, swap=0),
                 mmap(path='[stack]', rss=8192, size=139264, pss=8192, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=8192, anonymous=8192, swap=0),
                 mmap(path='[anon]', rss=946176, size=179245056, pss=946176, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=946176, referenced=946176, anonymous=946176, swap=0),
                 mmap(path='/lib/x86_64-linux-gnu/ld-2.15.so', rss=122880, size=151552, pss=13312, shared_clean=110592, shared_dirty=0, private_clean=0, private_dirty=12288, referenced=122880, anonymous=12288, swap=0),
                 mmap(path='[vsyscall]', rss=0, size=4096, pss=0, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=0, referenced=0, anonymous=0, swap=0),
                 mmap(path='[heap]', rss=4096, size=135168, pss=4096, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=4096, referenced=4096, anonymous=4096, swap=0),
                 mmap(path='[vdso]', rss=4096, size=4096, pss=0, shared_clean=4096, shared_dirty=0, private_clean=0, private_dirty=0, referenced=4096, anonymous=0, swap=0),
                 mmap(path='/home/ben/gocode/src/SampleMePlz/SampleMePlz', rss=2908160, size=6905856, pss=2908160, shared_clean=0, shared_dirty=0, private_clean=2879488, private_dirty=28672, referenced=2908160, anonymous=28672, swap=0)],
 'memory_percent': 0.025919821179310142,
 'name': 'SampleMePlz',
 'nice': 0,
 'num_ctx_switches': amount(voluntary=15, involuntary=18),
 'num_fds': 5,
 'num_threads': 6,
 'open_files': [],
 'pid': 111252,
 'ppid': 42061,
 'status': 'sleeping',
 'terminal': '/dev/pts/9',
 'threads': [thread(id=111252, user_time=0.0, system_time=0.0),
             thread(id=111253, user_time=0.0, system_time=0.0),
             thread(id=111254, user_time=0.0, system_time=0.0),
             thread(id=113972, user_time=0.0, system_time=0.0),
             thread(id=113973, user_time=0.0, system_time=0.0),
             thread(id=113974, user_time=0.0, system_time=0.0)],
 'uids': user(real=3008, effective=3008, saved=3008),
 'username': 'ben'}
  • 写回答

2条回答 默认 最新

  • duanchi8112 2015-07-09 21:37
    关注

    The short answer is no. The code is compiled leaving no information about what language/compiler produced it. You can look for symptoms of a go-program, like references to your GOPATH or sub directories of it, but not much more.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?