惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - Eric Lee

20230707-编程语言的变量覆盖 20230328-Epic Game更改修改更换安装目录 20230204 - 解决 Delphi 10.4 IDE 提示 socket error 10038 Access violation coreide270.bpl rtl270.bpl 20230126 - TurboGears 提示 builtins.NameError Session is not defined 20221112 - Find Device closed unexpectedly 问题解决 20220328 - BUG的出处 20220317 - 获取 .Net 版本的方法 20211015 - 解决华为 Matebook CPU 频率被锁在 0.39 GHz 的卡顿问题 20201118 - 解决CentOS7的RPMDB错误 rpmdb: BDB0113 Thread/process failed Thread died in Berkeley DB library 20201107 - 拯救 Discuz6 20201024 - 如何删除FF新鲜事 20201020 - 现代浏览器中表单自动完成功能带来的麻烦 20200331 - Zsh 下 使用 you-get 或 youtube-dl 时提示 no matches found 20200330 - Jetbrains IDE 提示 Unknown Module Type 的解决办法 20200320 - 解决 you-get 提示 urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)> 20200319 - 解决 macOS 上 zsh 提示 command not found 的问题 20200310 - 在macOS上删除LaunchPad中的顽固的带问号图标 20200221 - 记录云服务器中 cna12.dll 木马的解决 20190925 - 使 macOS 的 rm 命令删除到回收站的不完美办法
20190926 - macOS 下查看进程路径
Eric Lee · 2019-09-26 · via 博客园 - Eric Lee

首先,从 Activity Monitor 中查看进程 PID,然后使用以下命令查看。

另一个办法是,使用系统调用 proc_pidpath 。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <libproc.h>

int main (int argc, char* argv[])
{
    pid_t pid; int ret;
    char pathbuf[PROC_PIDPATHINFO_MAXSIZE];

    if ( argc > 1 ) {
        pid = (pid_t) atoi(argv[1]);
        ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf));
        if ( ret <= 0 ) {
            fprintf(stderr, "PID %d: proc_pidpath ();\n", pid);
            fprintf(stderr, "    %s\n", strerror(errno));
        } else {
            printf("proc %d: %s\n", pid, pathbuf);
        }
    }

    return 0;
}