iliaa           Mon Feb 17 20:07:58 2003 EDT

  Modified files:              
    /php4/ext/standard  basic_functions.c config.m4 exec.c exec.h 
  Log:
  Added nice() function, which allows changing of priority for the current
  process.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.580 
php4/ext/standard/basic_functions.c:1.581
--- php4/ext/standard/basic_functions.c:1.580   Mon Feb 17 01:28:06 2003
+++ php4/ext/standard/basic_functions.c Mon Feb 17 20:07:55 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.580 2003/02/17 06:28:06 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.581 2003/02/18 01:07:55 iliaa Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -422,6 +422,10 @@
        PHP_FE(proc_close,                                                             
                                                 NULL)
        PHP_FE(proc_terminate,                                                         
                                         NULL)
        PHP_FE(proc_get_status,                                                        
                                         NULL)
+#endif
+
+#ifdef HAVE_NICE
+       PHP_FE(nice,                                                                   
+                                         NULL)   
 #endif
 
        PHP_FE(rand,                                                                   
                                                 NULL)
Index: php4/ext/standard/config.m4
diff -u php4/ext/standard/config.m4:1.55 php4/ext/standard/config.m4:1.56
--- php4/ext/standard/config.m4:1.55    Sun Feb 16 17:28:00 2003
+++ php4/ext/standard/config.m4 Mon Feb 17 20:07:57 2003
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.55 2003/02/16 22:28:00 momo Exp $ -*- sh -*-
+dnl $Id: config.m4,v 1.56 2003/02/18 01:07:57 iliaa Exp $ -*- sh -*-
 
 divert(3)dnl
 
@@ -273,6 +273,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 \
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.92 php4/ext/standard/exec.c:1.93
--- php4/ext/standard/exec.c:1.92       Sat Jan 18 15:01:40 2003
+++ php4/ext/standard/exec.c    Mon Feb 17 20:07:57 2003
@@ -15,7 +15,7 @@
    | Author: Rasmus Lerdorf                                               |
    +----------------------------------------------------------------------+
  */
-/* $Id: exec.c,v 1.92 2003/01/18 20:01:40 iliaa Exp $ */
+/* $Id: exec.c,v 1.93 2003/02/18 01:07:57 iliaa Exp $ */
 
 #include <stdio.h>
 #include "php.h"
@@ -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)
@@ -486,6 +490,29 @@
        Z_STRVAL_P(return_value)[total_readbytes] = '\0';       
 }
 /* }}} */
+
+#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:
Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.18 php4/ext/standard/exec.h:1.19
--- php4/ext/standard/exec.h:1.18       Sat Feb 15 12:18:57 2003
+++ php4/ext/standard/exec.h    Mon Feb 17 20:07:57 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: exec.h,v 1.18 2003/02/15 17:18:57 wez Exp $ */
+/* $Id: exec.h,v 1.19 2003/02/18 01:07:57 iliaa Exp $ */
 
 #ifndef EXEC_H
 #define EXEC_H
@@ -31,6 +31,7 @@
 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 *);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to