Skip to content

Commit 5155097

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78402: pcntl_signal() misleading error message
2 parents 885b345 + cbb0efa commit 5155097

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ext/pcntl/pcntl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ PHP_FUNCTION(pcntl_signal)
10581058
zend_long signo;
10591059
zend_bool restart_syscalls = 1;
10601060
zend_bool restart_syscalls_is_null = 1;
1061+
char *error = NULL;
10611062

10621063
if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz|b!", &signo, &handle, &restart_syscalls, &restart_syscalls_is_null) == FAILURE) {
10631064
return;
@@ -1103,13 +1104,15 @@ PHP_FUNCTION(pcntl_signal)
11031104
RETURN_TRUE;
11041105
}
11051106

1106-
if (!zend_is_callable(handle, 0, NULL)) {
1107+
if (!zend_is_callable_ex(handle, NULL, 0, NULL, NULL, &error)) {
11071108
zend_string *func_name = zend_get_callable_name(handle);
11081109
PCNTL_G(last_error) = EINVAL;
1109-
php_error_docref(NULL, E_WARNING, "%s is not a callable function name error", ZSTR_VAL(func_name));
1110+
php_error_docref(NULL, E_WARNING, "Specified handler \"%s\" is not callable (%s)", ZSTR_VAL(func_name), error);
11101111
zend_string_release_ex(func_name, 0);
1112+
efree(error);
11111113
RETURN_FALSE;
11121114
}
1115+
ZEND_ASSERT(!error);
11131116

11141117
/* Add the function name to our signal table */
11151118
handle = zend_hash_index_update(&PCNTL_G(php_signal_table), signo, handle);

ext/pcntl/tests/pcntl_signal.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ bool(false)
4242
Warning: pcntl_signal(): Invalid signal %s
4343
bool(false)
4444

45-
Warning: pcntl_signal(): not callable is not a callable function name error in %s
45+
Warning: pcntl_signal(): Specified handler "not callable" is not callable (%s) in %s
4646
bool(false)
4747
ok

0 commit comments

Comments
 (0)