PHP Velho Oeste 2024

setproctitle

(PECL proctitle >= 0.1.0)

setproctitleSet the process title

Descrierea

setproctitle ( string $title ) : void

Sets the process title of the current process.

Parametri

title

The title to use as the process title.

Valorile întoarse

Nu este întoarsă nici o valoare.

Exemple

Example #1 setproctitle() example

Running the example below will change the process title (visible with ps a for example).

<?php
setproctitle
("myscript");
?>

Exemplul de mai sus va afișa ceva similar cu:

$ ps a
  PID TTY      STAT   TIME COMMAND
 1168 pts/3    S      0:00 myscript                                                                                                                         

A se vedea și

add a note add a note

User Contributed Notes 2 notes

up
4
james at ifixit dot com
10 years ago
You should use cli_set_process_title() ( http://php.net/manual/en/function.cli-set-process-title.php ) instead; it's less dangerous and less buggy, and part of PHP itself as of 5.5.
up
1
zodbd421 at gmail dot com
11 years ago
Note that this extension is considered buggy.  See https://wiki.php.net/rfc/cli_process_title, which says:

"...but it is incomplete and might lead to memory corruption on Linux (or any OS which does not support setproctitle.

The reason is the extension only has access to original argv[0] (that comes from main()). argv and environ(7) are in contiguous memory space on Linux. The extension presumes that argv[0] can accomodate 128 characters, but usually that is not possible because argv[0] is “php”. When this happens, the extension will scribble on argv[1], argv[2], etc., and maybe even environ and this can have destructive side effects on the running program."
To Top