mirror of
https://github.com/php/php-src.git
synced 2025-01-21 11:13:38 +08:00
Added nice() function, which allows changing of priority for the current
process.
This commit is contained in:
parent
19a9b4f310
commit
0fd1009fcc
@ -424,6 +424,10 @@ function_entry basic_functions[] = {
|
||||
PHP_FE(proc_get_status, NULL)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NICE
|
||||
PHP_FE(nice, NULL)
|
||||
#endif
|
||||
|
||||
PHP_FE(rand, NULL)
|
||||
PHP_FE(srand, NULL)
|
||||
PHP_FE(getrandmax, NULL)
|
||||
|
@ -274,6 +274,11 @@ PHP_CHECK_FUNC(res_nsend, resolv, bind, socket)
|
||||
PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
|
||||
dnl already done PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket)
|
||||
|
||||
dnl
|
||||
dnl Check for the availability of the nice function
|
||||
dnl
|
||||
PHP_CHECK_FUNC(nice)
|
||||
|
||||
PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \
|
||||
cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c filestat.c \
|
||||
flock_compat.c formatted_print.c fsock.c head.c html.c image.c \
|
||||
|
@ -45,6 +45,10 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_NICE && HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* {{{ php_Exec
|
||||
* If type==0, only last line of output is returned (exec)
|
||||
* If type==1, all lines will be printed and last lined returned (system)
|
||||
@ -487,6 +491,29 @@ PHP_FUNCTION(shell_exec)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef HAVE_NICE
|
||||
/* {{{ proto bool nice(int priority)
|
||||
Change the priority of the current process */
|
||||
PHP_FUNCTION(nice)
|
||||
{
|
||||
long pri;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &pri) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
nice(pri);
|
||||
if (errno) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only a super user may attempt to increase the process priority.");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
@ -31,6 +31,7 @@ PHP_FUNCTION(proc_open);
|
||||
PHP_FUNCTION(proc_get_status);
|
||||
PHP_FUNCTION(proc_close);
|
||||
PHP_FUNCTION(proc_terminate);
|
||||
PHP_FUNCTION(nice);
|
||||
PHP_MINIT_FUNCTION(proc_open);
|
||||
|
||||
char *php_escape_shell_cmd(char *);
|
||||
|
Loading…
Reference in New Issue
Block a user