summaryrefslogtreecommitdiff
path: root/ext/standard/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/exec.c')
-rw-r--r--ext/standard/exec.c27
1 files changed, 27 insertions, 0 deletions
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