summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/basic_functions.c4
-rw-r--r--ext/standard/config.m45
-rw-r--r--ext/standard/exec.c27
-rw-r--r--ext/standard/exec.h1
4 files changed, 37 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 1325930511..942d381380 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -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)
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index 28a945f0b7..2932184552 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -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 \
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 13ed72a6ac..d37dcb6cd6 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.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
diff --git a/ext/standard/exec.h b/ext/standard/exec.h
index 796701317f..fd1c5e39c5 100644
--- a/ext/standard/exec.h
+++ b/ext/standard/exec.h
@@ -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 *);