.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" %%%LICENSE_END .\" .\" 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) .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka .\" all rights reserved. .\" Translated 1997-12-19, HIROFUMI Nishizuka .\" Updated 2000-06-18, Kentaro Shirakata .\" Updated 2005-11-19, Akihiro MOTOKI .\" .TH PUTENV 3 2014\-08\-19 GNU "Linux Programmer's Manual" .SH 名前 putenv \- 環境変数の変更または追加 .SH 書式 .nf \fB#include \fP .sp .\" Not: const char * \fBint putenv(char *\fP\fIstring\fP\fB);\fP .fi .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBputenv\fP(): _SVID_SOURCE || _XOPEN_SOURCE .SH 説明 \fBputenv\fP() 関数は、環境変数の追加または値の変更を行う。 引数 \fIstring\fP は \fIname\fP=\fIvalue\fP という形式を取る。 \fIname\fP が環境に存在しない場合は \fIstring\fP が環境に追加される。 \fIname\fP が環境に存在する場合は \fIname\fP の値は \fIvalue\fP に変更される。 \fIstring\fP が指している文字列は環境の一部となるので、 文字列を変更すると環境も変更される。 .SH 返り値 \fBputenv\fP() 関数は、成功すると 0 を返し、エラーの場合は 0 以外の値を返す。エラーが発生した場合、 \fIerrno\fP に原因を示す値が設定される。 .SH エラー .TP \fBENOMEM\fP 新しい環境を割り当てるのに十分な空きがない。 .SH 準拠 SVr4, POSIX.1\-2001, 4.3BSD. .SH 注意 .\" .LP .\" Description for libc4, libc5, glibc: .\" If the argument \fIstring\fP is of the form \fIname\fP, .\" and does not contain an \(aq=\(aq character, then the variable \fIname\fP .\" is removed from the environment. .\" If .\" .BR putenv () .\" has to allocate a new array \fIenviron\fP, .\" and the previous array was also allocated by .\" .BR putenv (), .\" then it will be freed. .\" In no case will the old storage associated .\" to the environment variable itself be freed. \fBputenv\fP() はリエントラントであることを求められていない。 glibc 2.0 ではリエントラントではない。 glibc 2.1 ではリエントラントである。 .LP バージョン 2.1.2 以降では、 glibc の実装は SUSv2 に準拠している。 \fBputenv\fP() で与えられたポインター \fIstring\fP が使われる。 この文字列は環境の一部となり、後で変更すると環境も変わる。 (従って、 \fBputenv\fP() を自動変数を引数として呼び出し、 \fIstring\fPが環境の一部のままで呼び出した関数から return するとエラーになる) しかし、glibc バージョン 2.0 から 2.1.1 まででは違っており、文字列のコピーが使われる。 これはメモリーリークを引き起こすだけでなく、 SUSv2 にも違反している。 .LP 4.4BSD バージョンでは、glibc 2.0 と同様にコピーを使う。 .LP SUSv2 ではプロトタイプから \fIconst\fP が取り除かれており、 glibc 2.1.3 もそのようになっている。 .SH 関連項目 \fBclearenv\fP(3), \fBgetenv\fP(3), \fBsetenv\fP(3), \fBunsetenv\fP(3), \fBenviron\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。