V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
gIrl1990
V2EX  ›  问与答

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

  •  
  •   gIrl1990 · Sep 14, 2019 · 2271 views
    This topic created in 2423 days ago, the information mentioned may be changed or developed.

    就是 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 replies    2019-09-14 19:06:18 +08:00
    ysc3839
        1
    ysc3839  
       Sep 14, 2019 via Android
    gIrl1990
        2
    gIrl1990  
    OP
       Sep 14, 2019
    @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 参数`
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2408 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 06:05 · PVG 14:05 · LAX 23:05 · JFK 02:05
    ♥ Do have faith in what you're doing.