当前位置: 技术问答>linux和unix
怎么根据进程名取进程ID
来源: 互联网 发布时间:2016-12-21
本文导语: 没有完整的busybox源码 pidof是怎么实现的? | strace -o pidof_log pidof X 看log调用到系统命令可以推算出来 open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 fcntl(3, F_GETFD) =...
没有完整的busybox源码
pidof是怎么实现的?
pidof是怎么实现的?
|
strace -o pidof_log pidof X
看log调用到系统命令可以推算出来
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fcntl(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
getdents(3, /* 282 entries */, 32768) = 7208
open("1/stat", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fef46943000
read(4, "1 (init) S 0 1 1 0 -1 4202752 79"..., 1024) = 247
close(4) = 0
munmap(0x7fef46943000, 4096) = 0
open("1/cmdline", O_RDONLY) = 4
open("14/stat", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fef46943000
read(4, "14 (watchdog/3) S 2 0 0 0 -1 221"..., 1024) = 163
close(4) = 0
munmap(0x7fef46943000, 4096) = 0
open("14/cmdline", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fef46943000
read(4, "", 1024) = 0
read(4, "", 1024) = 0
close(4) = 0
munmap(0x7fef46943000, 4096) = 0
stat("/proc/14/exe", 0x7fff033708a0) = -1 ENOENT (No such file or directory)
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。