php-internal-docs
8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_cli_process_title.c
Go to the documentation of this file.
1
/*
2
+----------------------------------------------------------------------+
3
| Copyright (c) The PHP Group |
4
+----------------------------------------------------------------------+
5
| This source file is subject to version 3.01 of the PHP license, |
6
| that is bundled with this package in the file LICENSE, and is |
7
| available through the world-wide-web at the following url: |
8
| https://www.php.net/license/3_01.txt |
9
| If you did not receive a copy of the PHP license and are unable to |
10
| obtain it through the world-wide-web, please send a note to |
11
| license@php.net so we can mail you a copy immediately. |
12
+----------------------------------------------------------------------+
13
| Author: Keyur Govande (kgovande@gmail.com) |
14
+----------------------------------------------------------------------+
15
*/
16
17
#ifdef HAVE_CONFIG_H
18
#include <config.h>
19
#endif
20
21
#include "
php.h
"
22
#include "
php_cli_process_title.h
"
23
#include "
ps_title.h
"
24
25
/* {{{ Return a boolean to confirm if the process title was successfully changed or not */
26
PHP_FUNCTION
(
cli_set_process_title
)
27
{
28
char
*title =
NULL
;
29
size_t
title_len;
30
int
rc;
31
32
if
(
zend_parse_parameters
(
ZEND_NUM_ARGS
(),
"s"
, &title, &title_len) ==
FAILURE
) {
33
RETURN_THROWS
();
34
}
35
36
rc =
set_ps_title
(title);
37
if
(rc ==
PS_TITLE_SUCCESS
) {
38
RETURN_TRUE
;
39
}
40
41
php_error_docref
(
NULL
,
E_WARNING
,
"cli_set_process_title had an error: %s"
,
ps_title_errno
(rc));
42
RETURN_FALSE
;
43
}
44
/* }}} */
45
46
/* {{{ Return a string with the current process title. NULL if error. */
47
PHP_FUNCTION
(
cli_get_process_title
)
48
{
49
size_t
length = 0;
50
const
char
* title =
NULL
;
51
int
rc;
52
53
if
(
zend_parse_parameters_none
() ==
FAILURE
) {
54
RETURN_THROWS
();
55
}
56
57
rc =
get_ps_title
(&length, &title);
58
if
(rc !=
PS_TITLE_SUCCESS
) {
59
php_error_docref
(
NULL
,
E_WARNING
,
"cli_get_process_title had an error: %s"
,
ps_title_errno
(rc));
60
RETURN_NULL
();
61
}
62
63
RETURN_STRINGL
(title, length);
64
}
65
/* }}} */
NULL
#define NULL
Definition
gdcache.h:45
php_error_docref
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition
main.c:1173
php.h
PHP_FUNCTION
#define PHP_FUNCTION
Definition
php.h:364
php_cli_process_title.h
cli_set_process_title
cli_set_process_title(string $title)
Definition
php_cli_process_title.stub.php:3
cli_get_process_title
cli_get_process_title()
Definition
php_cli_process_title.stub.php:5
ps_title_errno
const char * ps_title_errno(int rc)
Definition
ps_title.c:307
get_ps_title
int get_ps_title(size_t *displen, const char **string)
Definition
ps_title.c:397
set_ps_title
int set_ps_title(const char *title)
Definition
ps_title.c:340
ps_title.h
PS_TITLE_SUCCESS
#define PS_TITLE_SUCCESS
Definition
ps_title.h:20
zend_parse_parameters
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition
zend_API.c:1300
ZEND_NUM_ARGS
#define ZEND_NUM_ARGS()
Definition
zend_API.h:530
RETURN_STRINGL
#define RETURN_STRINGL(s, l)
Definition
zend_API.h:1044
RETURN_FALSE
#define RETURN_FALSE
Definition
zend_API.h:1058
RETURN_NULL
#define RETURN_NULL()
Definition
zend_API.h:1036
zend_parse_parameters_none
#define zend_parse_parameters_none()
Definition
zend_API.h:353
RETURN_THROWS
#define RETURN_THROWS()
Definition
zend_API.h:1060
RETURN_TRUE
#define RETURN_TRUE
Definition
zend_API.h:1059
E_WARNING
#define E_WARNING
Definition
zend_errors.h:24
FAILURE
@ FAILURE
Definition
zend_types.h:61
sapi
cli
php_cli_process_title.c
Generated on Sat Aug 23 2025 01:46:13 for php-internal-docs by
1.13.2