rfc:cli_process_title
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:cli_process_title [2013/02/07 05:30] – [Implementation] keyur | rfc:cli_process_title [2013/03/08 00:12] – Fixing status keyur | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Request for Comments: PHP CLI changing process title support ====== | ====== Request for Comments: PHP CLI changing process title support ====== | ||
- | * Version: 1.0 | + | * Version: 1.3 |
* Date: 2013-02-06 | * Date: 2013-02-06 | ||
* Author: Keyur Govande < | * Author: Keyur Govande < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 11: | Line 11: | ||
This RFC proposes a new way of setting a PHP CLI process' | This RFC proposes a new way of setting a PHP CLI process' | ||
+ | This is very helpful when using PHP as a daemon, for example: [[https:// | ||
+ | |||
+ | '' | ||
+ | |||
+ | Currently, there are 2 ways to debug what job a process is doing: attach gdb and introspect the appropriate data structure. Or log the process-pid to a file at job start-up and match it up. | ||
+ | |||
+ | Both are doable, but time consuming and having functionality in the language to set the title would solve the problem nicely. | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 20: | Line 27: | ||
* On Linux: The init method deep-copies argv and environ and these copies are returned to main() for use during the program. The original argv and environ are saved by init. This contiguous block is then used to store the the new title. The OS reads from argv[0] onwards when ps(1) or top(1) or / | * On Linux: The init method deep-copies argv and environ and these copies are returned to main() for use during the program. The original argv and environ are saved by init. This contiguous block is then used to store the the new title. The OS reads from argv[0] onwards when ps(1) or top(1) or / | ||
* On BSD without [[http:// | * On BSD without [[http:// | ||
- | * On systems with support for [[http:// | + | * On systems with support for [[http:// |
- | * On Windows: the title is set as an Windows | + | * On Windows: the title is for the ' |
Support for setting the title is also built into the cli-server SAPI. | Support for setting the title is also built into the cli-server SAPI. | ||
Line 32: | Line 39: | ||
$title = "This is a test title"; | $title = "This is a test title"; | ||
- | if (!is_cli_ps_title_available()) { | + | if (!cli_set_process_title($title)) { |
- | echo "Not supported on this OS\n"; | + | echo "Unable to set title\n"; |
exit(1); | exit(1); | ||
- | } | ||
- | |||
- | if (!set_cli_ps_title($title)) { | ||
- | echo " | ||
- | exit(2); | ||
} | } | ||
sleep(15); | sleep(15); | ||
+ | echo cli_get_process_title() . " | ||
</ | </ | ||
Line 49: | Line 52: | ||
* Linux: {{: | * Linux: {{: | ||
* FreeBSD 9.0: {{: | * FreeBSD 9.0: {{: | ||
- | * Windows 7: {{:rfc:windows_ps_title.png?200|}} | + | * Windows 7: {{:rfc:windows_ps_title_console.png? |
+ | * OS X Lion: {{: | ||
- | ===== Proposal and Patch ===== | ||
- | The patch (including tests) is [[https:// | + | ===== Specification ===== |
+ | ==== Description ==== | ||
+ | |||
+ | bool cli_set_process_title(string $title) | ||
+ | |||
+ | '' | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | |||
+ | **title** | ||
+ | |||
+ | ==== Description ==== | ||
+ | |||
+ | string cli_get_process_title() | ||
+ | |||
+ | '' | ||
+ | |||
+ | Note that this returned string may not match what ps/top would show; for example on FreeBSD in ps, you would see the process name as "php: title (php)" where // | ||
+ | |||
+ | If the method fails for any reason, a WARNING is emitted and NULL is returned; the most common cause of failure being the operating system is not supported. | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | |||
+ | None | ||
+ | |||
+ | ===== Patch ===== | ||
+ | |||
+ | The pull request (including tests) based on PHP-5.5 is [[https:// | ||
===== Voting ===== | ===== Voting ===== | ||
The PHP language is not changed, so a 50% + 1 majority is required. | The PHP language is not changed, so a 50% + 1 majority is required. | ||
+ | |||
+ | Voting ends March 4th, 2013. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Changelog ===== | ===== Changelog ===== | ||
* 1.0 (2012-02-06): | * 1.0 (2012-02-06): | ||
+ | * 1.1 (2012-02-07): | ||
+ | * 1.2 (2012-02-21): | ||
+ | * 1.3 (2012-02-26): |
rfc/cli_process_title.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1