V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
gIrl1990
V2EX  ›  问与答

MacOS: 终端上敲命令运行一个 gui 程序,如何使它成为 rootpid 的子进程?

  •  
  •   gIrl1990 · 2019-09-14 16:35:03 +08:00 · 1481 次点击
    这是一个创建于 1657 天前的主题,其中的信息可能已经有所发展或是发生改变。

    就是 Chrome 么,我想带参数启动。

    • 网上也有那种调整 /Applications 内 Google Chrome 命令的,但这种 版本升级 后是不是又得重新弄?

    • 所以我就每次在iTerm2中启动 Chrome,因为 iTerm2 我是一直开着的。

    • 但这样 Chrome 就是 iTerm2 的子进程了。在一些统计方面就统计不到 Chrome 了。比如耗电就显示 iTerm2 很耗电,实际是 Chrome 耗电

    • 比如exec可以把 shell 替换当前 shell,那有木有启动程序但调整 pid 的?

    # 我是这样写的
    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --参数 2>/dev/null &
    
    2 条回复    2019-09-14 19:06:18 +08:00
    ysc3839
        1
    ysc3839  
       2019-09-14 17:48:26 +08:00 via Android
    gIrl1990
        2
    gIrl1990  
    OP
       2019-09-14 19:06:18 +08:00
    @ysc3839 哇,谢谢。open --args
    All remaining arguments are passed to the opened application in the argv parameter to main(). These arguments are not opened or interpreted by the open tool.

    `open /Applications/Google\ Chrome.app --args chrome 参数`
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5405 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:52 · PVG 15:52 · LAX 00:52 · JFK 03:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.