.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Single UNIX Specification, Version 2 .\" Modified Thu Apr 8 15:00:12 1993, David Metcalfe .\" Modified Sat Jul 24 18:44:45 1993, Rik Faith (faith@cs.unc.edu) .\" Modified Fri Feb 14 21:47:50 1997 by Andries Brouwer (aeb@cwi.nl) .\" Modified Mon Oct 11 11:11:11 1999 by Andries Brouwer (aeb@cwi.nl) .\" Modified Wed Nov 10 00:02:26 1999 by Andries Brouwer (aeb@cwi.nl) .\" Modified Sun May 20 22:17:20 2001 by Andries Brouwer (aeb@cwi.nl) .\" Translated into Spanish Thu Mar 5 15:33:46 CET 1998 by .\" Gerardo Aburruzaga García .\" Translation revised Tue Apr 18 2000 by Juan Piernas .\" .TH PUTENV 3 "8 abril 1993" "GNU" "Manual del Programador de Linux" .SH NOMBRE putenv \- cambia o añade una variable de ambiente .SH SINOPSIS .nf .B #include .sp .BI "int putenv(char *" cadena ); .\" Not: const char * .fi .SH DESCRIPCIÓN La función \fBputenv()\fP añade o cambia el valor de variables de entorno o ambiente. El argumento \fIcadena\fP es de la forma \fInombre\fP=\fIvalor\fP. Si \fInombre\fP no existe ya en el ambiente, entonces \fIcadena\fP se añade al entorno. Si \fInombre\fP sí existe, entonces el valor de \fInombre\fP en el ambiente se cambia a \fIvalor\fP. La cadena apuntada por \fIcadena\fP se convierte en parte del entorno, por lo que cambiar la cadena modifica el entorno. .SH "VALOR DEVUELTO" La función \fBputenv()\fP devuelve cero si acaba bien, ó \-1 en caso de error. .SH ERRORES .TP .B ENOMEM Espacio insuficiente para alojar el nuevo ambiente. .SH NOTA No es necesario que la función \fBputenv()\fP sea reentrante, y la de libc4, libc5 y glibc2.0 no lo es, pero la versión de glibc2.1 sí. .LP Descripción para libc4, libc5, glibc: si el argumento \fIcadena\fP es de la forma \fIname\fP, y no contiene el carácter `=', entonces la variable \fIname\fP se elimina del entorno. Si \fBputenv()\fP tiene que reservar un nuevo array \fIenviron\fP, y el array previo también fue reservado por \fBputenv()\fP, entonces será liberado. En ningún caso se liberará el anterior almacenamiento asociado a la propia variable de entorno. .LP Las versiones de libc4 y libc5 siguen SUSv2: se usa el puntero \fIcadena\fP dado a \fBputenv()\fP. En particular, esta cadena se convierte en parte del entorno. El cambiarla después modificará el entorno. (De esta manera, es un error llamar a \fBputenv()\fP pasando como argumento una variable automática, y después volver de la función invocadora mientras \fIcadena\fP forma todavía parte del entorno.) Sin embargo, glibc 2.0-2.1.1 difieren: se usa una copia de la cadena. Por un lado, esto provoca una pérdida de memoria y, por otro lado, viola SUSv2. Esto se ha solucionado en glibc2.1.2. .LP La versión de BSD4.4, como la de glibc 2.0, usa una copia. .LP SUSv2 elimina `const' del prototipo, y así lo hace glibc 2.1.3. .SH "CONFORME A" SVID 3, POSIX, BSD 4.3 .SH "VÉASE TAMBIÉN" .BR getenv (3), .BR setenv (3), .BR clearenv (3), .BR unsetenv (3), .BR environ (7)