Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved CLI process title

Comments in 'Plugin Development' started by PocketKiller, Aug 30, 2016.

  1. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Hello,

    Note: This is PocketMine-MP source code question.

    I tried to use cli_set_process_title() on my project (Not related to PocketMine), it didn't work with cygwin's MinTTY that PM uses, though it returned TRUE, it only worked on The Command Prompt.
    If I search in the PM code, I only find one cli_set_process_title() on the code, that outputs PocketMine-MP | (Version).
    Then how is the process title changing everytime TSL/Memory/Players etc change?

    Thanks for your help.
    Last edited: Aug 31, 2016
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Same issue. Never really found a solution to it.
  3. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Confusing, If I use cli_get_process_title(), it returns the one I am trying to set, while I see it didn't change?!
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    cli_set_process_title won't change title of terminal window, it will name of the process and you'll see it in Task manager, I'll post a screenshot in a moment.

    The way PocketMine changes title of windows is by this code
    PHP:
    echo "\x1b]0;" $this->getName() . " " .
           
    $this->getPocketMineVersion() .
           
    " | Online " count($this->players) . "/" $this->getMaxPlayers() .
           
    " | Memory " $usage .
           
    " | U " round($this->network->getUpload() / 10242) .
           
    " D " round($this->network->getDownload() / 10242) .
           
    " kB/s | TPS " $this->getTicksPerSecond() .
           
    " | Load " $this->getTickUsage() . "%\x07";
    https://github.com/PocketMine/PocketMine-MP/blob/master/src/pocketmine/Server.php#L2347-L2354

    Here is the result of cli_set_process_title
    [​IMG]

    Test this out yourself
    Code:
    php -r 'echo "\x1b]0Hello World!\x07";'
    
    Last edited: Aug 31, 2016
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Thanks very much!
    I thought changing the process title will also change the title.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    How does it actually work?
    HotFireyDeath likes this.

Share This Page

Advertisement