putenv(3c) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

putenv(3c)

putenv(3C)               Standard C Library Functions               putenv(3C)

NAME
       putenv - change or add value to environment

SYNOPSIS
       #include <stdlib.h>

       int putenv(char *string);

DESCRIPTION
       The  putenv() function makes the value of the environment variable name
       equal to value by altering an existing variable or creating a new  one.
       In either case, the string pointed to by string becomes part of the en‐
       vironment, so altering the string will change the environment.


       The  string  argument  points  to  a string of the form name=value. The
       space used by string is no longer used once a new string-defining  name
       is passed to putenv().


       If  the  string  argument  points to a string without an '=' character,
       then the equivalent of unsetenv(3C) is performed.


       The putenv() function may use malloc(3C) to enlarge the environment.


       After putenv() is called, environment variables are not in alphabetical
       order.

RETURN VALUES
       Upon successful completion, putenv() returns 0. Otherwise, it returns a
       non-zero value and sets errno to indicate the error.

ERRORS
       The putenv() function may fail if:

       EINVAL    The string argument is  not  of  the  form  "name=value",  or
                 "name", as described above.


       ENOMEM    Insufficient memory was available.


USAGE
       The putenv() function can be safely called from multithreaded programs.
       Caution  must  be  exercised when using this function and getenv(3C) in
       multithreaded programs. These functions examine and modify the environ‐
       ment list, which is shared by all threads in a program. The system pre‐
       vents the list from being  accessed  simultaneously  by  two  different
       threads.  It  does  not, however, prevent two threads from successively
       accessing the environment list using putenv() or getenv().

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelSafe _ Standard‐
       See standards(7).


SEE ALSO
       exec(2),  getenv(3C),  malloc(3C),  setenv(3C),  unsetenv(3C),  attrib‐
       utes(7), environ(7), standards(7)

WARNINGS
       The string argument should not be an automatic variable. It  should  be
       declared  static  if it is declared within a function because it cannot
       be automatically declared. A potential error is to call putenv() with a
       pointer to an automatic variable as the argument and to then  exit  the
       calling function while string is still part of the environment.

HISTORY
       Support  for string arguments without an '=' character to unset a vari‐
       able was added in Oracle Solaris 11.4.27.


       The putenv() function has been included in all Sun and Oracle  releases
       of Solaris.

Oracle Solaris 11.4               4 Aug 2022                        putenv(3C)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3