|
|
 |
getmypid (PHP 3, PHP 4, PHP 5) getmypid -- Obtiene el ID del proceso PHP Descripciónint getmypid ( void )
Devuelve el ID del proceso PHP actual, o FALSE si ocurre un
error.
| Aviso |
Los IDs de proceso no son únicos, por lo tanto son una
fuente débil de entropÃa. Es recomendable no
depender en ids de proceso en contextos sujetos a
consideraciones de seguridad.
|
Vea también getmygid(),
getmyuid(),
get_current_user(),
getmyinode(), y
getlastmod().
kroczu at interia dot pl
19-Dec-2005 04:59
<?
function getpidinfo($pid, $ps_opt="aux"){
$ps=shell_exec("ps ".$ps_opt."p ".$pid);
$ps=explode("\n", $ps);
if(count($ps)<2){
trigger_error("PID ".$pid." doesn't exists", E_USER_WARNING);
return false;
}
foreach($ps as $key=>$val){
$ps[$key]=explode(" ", ereg_replace(" +", " ", trim($ps[$key])));
}
foreach($ps[0] as $key=>$val){
$pidinfo[$val] = $ps[1][$key];
unset($ps[1][$key]);
}
if(is_array($ps[1])){
$pidinfo[$val].=" ".implode(" ", $ps[1]);
}
return $pidinfo;
}
?>
Pure-PHP
21-Mar-2005 02:26
You can use this function also to avoid more than one instance of your app.
You can also use this class.
http://www.pure-php.de/node/20
Usage:
<?php
inlude("ProcessHandler.class.php");
if(ProcessHandler::isActive()){
die("Already running!\n";);
}else{
ProcessHandler::activate();
}
?>
brooke at jump dot net
24-Oct-2003 05:49
One good use for this is deciding on a concurrency-safe temporary file or directory name. You can be assured that no two processes on the same server have the same PID, so this is enough to avoid collisions. For example:
$tmpfile = "/tmp/foo_".getmypid();
// Use $tmpfile...
// Use $tmpfile...
// Use $tmpfile...
unlink ($tmpfile);
If you are sharing /tmp over the network (which is odd....) then you can, of course, mix in the PHP server's IP address.
Webmaster at PopCart dot com
26-Mar-2003 04:29
$_SERVER['REMOTE_ADDR'] is a bad thing to use these days.
Since AOL, and MSN Browsers change the IP address at the
most uncomfortable times, such as going from unsecure to
secure mode, you cannot rely on it staying the same anymore.
Using this Octal-Quad for hanging on to a user, such as in
shopping carts will ALWAYS FAIL with AOL browsers. FYI.
10-Sep-2002 02:46
Something you can use to combine several weak entropy sources, into a better init value for srand() and mt_srand():
mt_srand(time()
^ (int)microtime()
^ ip2long($_SERVER['REMOTE_ADDR'])
^ (int)$_SERVER['REMOTE_PORT']
^ @getmypid()
^ @disk_free_space('/tmp')
);
Note that getmypid() may return 0 on some shared PHP installations that have excluded it for "safe"...
The safe mode also exclude the disk_free_space(directory) function call in some cases, for security reason. This explains the use of the @ operator to ignore warnings... the directory should be a highly active directory, which is accessible and typically used for temporary contents generated by PHP.
The above code combines all these sources using XOR binary operations, to avoid 32-bit overflows.
carl at NOSPAM dot thep dot lu dot se
05-Aug-2001 04:07
As it is very unlikely today that there will be two PHP processes with
the same process ID within the same microsecond, this function can
be used for something like srand((int)microtime() ^ getmypid() ^ time())
to have a decent chance of avioding a collision.
<p>
Just relying on the time in microseconds is a rather Bad Thing to do, since
a contect switch might very well take a lot less than that, so there's a decent
chance of two simultaneous request to get the same ID.
<P>
If you're running your php script upon an HTTP request, you might even want to toss in the IP addy of the remote host in your seed for a bit of extra entropy. You can't be too paranoid when it comes to 'random' numbers.
<p>(Side note: I tried using hardware to generate random numbers, but
with my setup it took just about forever to gather enough entropy.
All hail ran3()! )
| |
| | Citas célebres | En los comienzos de un amor, los amantes hablan de porvenir; en su declive, hablan del pasado. André Maurois Escritor francés (1885-1970) | | Citas en tu mail | | ©Contenidos Gratis |
| Chiste de... Varios | | Póquer destapado | Después de una mano de póquer pregunta uno al perdedor:
- ¿Por qué subió usted la apuesta? Está bien claro que el otro tenía cuatro ases. En cambio, ¿usted que tenía?
- Dos reinas...y seis whiskys. | | Chistes en tu mail | | ©ContenidosGratis |
| Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos |  | Cake Mania Jugadores: 6835 Categoría del juego: Acción Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero. |
|  | Rainbow Web Jugadores: 2199 Categoría del juego: Puzzles Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente. |
|  | Mahjongg Fortuna Jugadores: 12462 Categoría del juego: Solitarios Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta. |
|  | Chainz 2 Jugadores: 6955 Categoría del juego: Puzzles Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más. |
|  | Delicious Jugadores: 4405 Categoría del juego: Acción Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues! |
|  | Bookworm Jugadores: 4568 Categoría del juego: Palabras Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos! |
|  | Zuma Jugadores: 4976 Categoría del juego: Acción Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás! |
|  | Jewel of Atlantis Jugadores: 3798 Categoría del juego: Puzzles Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis. |
|  | Jewel Quest Jugadores: 3727 Categoría del juego: Puzzles Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos! |
|  | Bejeweled 2 Jugadores: 3659 Categoría del juego: Puzzles Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca. |
|
|