Scroll to navigation

PUTENV(3) Manual do Programador do Linux PUTENV(3)

NOME

putenv - altera ou adiciona um variável de ambiente

SINOPSE

#include <stdlib.h>
int putenv(char *string);


Requisitos de macro de teste de recursos para o glibc (consulte feature_test_macros(7)):

putenv(): _XOPEN_SOURCE
|| /* Desde o glibc 2.19: */ _DEFAULT_SOURCE
|| /* Glibc versões <= 2.19: */ _SVID_SOURCE

DESCRIÇÃO

A função putenv() altera ou adiciona o valor da variável de ambiente. O argumento string está na forma name=value. Se name ainda não existir no ambiente, então string é adicionada ao ambiente. Se name não existe,então o valor de name no ambiente é alterado para value. A seqüencia indicada por string torna-se parte do ambiente, alterando, então, as mudanças de 'string' no ambiente.

VALOR DE RETORNO

The putenv() function returns zero on success, or nonzero if an error occurs. In the event of an error, errno is set to indicate the cause.

ERROS

Espaço insuficiente para alocar o novo ambiente.

ATRIBUTOS

Para uma explicação dos termos usados nesta seção, consulte attributes(7).

Interface Atributo Valor
putenv() Thread safety MT-Unsafe const:env

DE ACORDO COM

POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.

NOTAS

The putenv() function is not required to be reentrant, and the one in glibc 2.0 is not, but the glibc 2.1 version is.

Since version 2.1.2, the glibc implementation conforms to SUSv2: the pointer string given to putenv() is used. In particular, this string becomes part of the environment; changing it later will change the environment. (Thus, it is an error is to call putenv() with an automatic variable as the argument, then return from the calling function while string is still part of the environment.) However, glibc versions 2.0 to 2.1.1 differ: a copy of the string is used. On the one hand this causes a memory leak, and on the other hand it violates SUSv2.

The 4.4BSD version, like glibc 2.0, uses a copy.

SUSv2 removes the const from the prototype, and so does glibc 2.1.3.

VEJA TAMBÉM

clearenv(3), getenv(3), setenv(3), unsetenv(3), environ(7)

COLOFÃO

Esta página faz parte da versão 4.16 do projeto Linux man-pages. Uma descrição do projeto, informações sobre relatórios de bugs e a versão mais recente desta página podem ser encontradas em https://www.kernel.org/doc/man-pages/.

TRADUÇÃO

A tradução para português brasileiro desta página man foi criada por Ricardo C.O.Freitas <english.quest@best-service.com> e André Luiz Fassone <lonely_wolf@ig.com.br>

Esta tradução é uma documentação livre; leia a Licença Pública Geral GNU Versão 3 ou posterior para as condições de direitos autorais. Nenhuma responsabilidade é aceita.

Se você encontrar algum erro na tradução desta página de manual, envie um e-mail para a lista de discussão de tradutores.

15 março 2016 GNU