ID: 29479 Updated by: magical...@php.net Reported By: black at scene-si dot org -Status: Suspended +Status: Closed Bug Type: Feature/Change Request Operating System: linux PHP Version: 6CVS New Comment:
This feature is now covered by the proctitle pecl extension, which is based on code written by the different http://pecl.php.net/proctitle I believe this bug can now be closed. Previous Comments: ------------------------------------------------------------------------ [2009-01-21 22:35:47] paj...@php.net hi! I would suggest to simply propose it to pecl-dev. That's the place to discussion proposals for PECL. cheers, ------------------------------------------------------------------------ [2009-01-21 20:56:48] magical...@php.net Just for info since a lot of people seems to be looking for this kind of solution (I'm one of them), I've hosted the proctitle extension on a SVN repository, updated and fixed. Available at: http://ookoo.org/svn/proctitle/ Please let me know if you want to add things to this extension. I tested it with PHP 5.2.8 and PHP 5.3.0alpha3, without problems. ------------------------------------------------------------------------ [2008-06-09 22:52:55] lindsay dot snider at gmail dot com Here is a shorter version based off of xdecock's code which has been working well. I see value in having this available when using PHP in CLI mode. ------------------------------------------- #include <php.h> #include <SAPI.h> #include <dlfcn.h> #include <string.h> static char *argv0 = NULL; #define MAX_TITLE_LENGTH 128 void setproctitle(char *title) { char buffer[MAX_TITLE_LENGTH]; int tlen = strlen(title); memset(buffer, 0x20, MAX_TITLE_LENGTH); buffer[MAX_TITLE_LENGTH-1] = '\0'; if( tlen < (MAX_TITLE_LENGTH-1) ) memcpy(buffer, title, tlen); if( argv0 ) snprintf(argv0, MAX_TITLE_LENGTH, "%s", buffer); } void set_proctitle_init() { sapi_module_struct *symbol = NULL; symbol = (sapi_module_struct *)dlsym(NULL, "sapi_module"); if( symbol ) argv0 = symbol->executable_location; } PHP_FUNCTION(setproctitle) { char *title; long tlen; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&title, &tlen) == FAILURE) RETURN_FALSE; setproctitle(title); } ------------------------------------------------------------------------ [2007-06-06 12:54:17] xdecock at gmail dot com I've tried to make a port of the apache thing used for wikipedia to a more generic one. If it can be usefull for anyone (only tested it on cli, as i search the way of doing this for cli primary) Not sure how good is this method, at first seen, it works proctitle.h & config.m4 are almost the same (except for MREQUEST_INIT & MREQUEST_SHUTDOWN), but it is not usefull for CLI the url for those files: http://wikipedia.svn.sourceforge.net/viewvc/wikipedia/trunk/extensions/pecl-proctitle/php_proctitle.h?revision=9174&view=markup #proctitle.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | lice...@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: | +----------------------------------------------------------------------+ $Id$ */ #define MAXTITLE 1024 #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <syslog.h> #include "php.h" #include "php_ini.h" #include "SAPI.h" #include "ext/standard/info.h" #include "php_proctitle.h" #include <dlfcn.h> /* If you declare any globals in php_proctitle.h uncomment this: ZEND_DECLARE_MODULE_GLOBALS(proctitle) */ /* True global resources - no need for thread safety here */ static int le_proctitle; static char *proctitle_argv=NULL; static char process_base_name[MAXTITLE+1]; #ifndef HAVE_PROCTITLE void setproctitle(char *title) { if (proctitle_argv){ sprintf(proctitle_argv,process_base_name,title); } } #endif /* {{{ proctitle_functions[] * * Every user visible function must have an entry in proctitle_functions[]. */ function_entry proctitle_functions[] = { PHP_FE(setproctitle, NULL) /* For testing, remove later. */ {NULL, NULL, NULL} /* Must be the last line in proctitle_functions[] */ }; /* }}} */ /* {{{ proctitle_module_entry */ zend_module_entry proctitle_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "proctitle", proctitle_functions, PHP_MINIT(proctitle), PHP_MSHUTDOWN(proctitle), NULL, /* Replace with NULL if there's nothing to do at request start */ NULL, /* Replace with NULL if there's nothing to do at request end */ PHP_MINFO(proctitle), #if ZEND_MODULE_API_NO >= 20010901 "0.1", /* Replace with version number for your extension */ #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_PROCTITLE ZEND_GET_MODULE(proctitle) #endif /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(proctitle) { sapi_module_struct *symbol; if(!proctitle_argv) { symbol=(sapi_module_struct *)dlsym(NULL,"sapi_module"); if (symbol){ sprintf(process_base_name,"PHP %s: %%s",symbol->name); proctitle_argv=symbol->executable_location; } } setproctitle("php_init"); return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(proctitle) { setproctitle("php_deinit"); return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(proctitle) { php_info_print_table_start(); php_info_print_table_header(2, "proctitle support", "enabled"); php_info_print_table_end(); } /* }}} */ PHP_FUNCTION(setproctitle) { char *string = NULL; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &str_len) == FAILURE) { setproctitle("System: Erreur"); RETURN_NULL(); } setproctitle(string); RETURN_BOOL(1); } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 * vim<600: noet sw=4 ts=4 */ ------------------------------------------------------------------------ [2006-08-22 21:22:51] jdoak at google dot com Is there currently a way to do this in php 5? It doesn't appear that the pecl module listed below is actually around any longer: http://cvs.sourceforge.net/viewcvs.py/wikipedia/extensions/pecl-proctitl e/ and a search for it turned up nothing. I'm just curious if this has been implemented or is this possible now on linux systems? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/29479 -- Edit this bug report at http://bugs.php.net/?id=29479&edit=1