--- Begin Message ---
Subject: |
Re: guile-1.5.6: some build comments: putenv() problems |
Date: |
Mon, 1 Apr 2002 09:19:15 -0700 (MST) |
>> ...
>> Nelson> ERROR: srfi-19.test: SRFI date/time library: #<procedure
>> time-utc->date (time . tz-offset)> respects local DST if no TZ-OFFSET given -
>> arguments: ((system-error "putenv" "~A" ("No such file or directory") (2)))
>>
>> How is putenv's return code documented on Solaris? Looks like putenv
>> is returning <0, which Guile, perhaps wrongly, interprets as an error.
>> ...
On Solaris 2.8, "man putenv" says:
>> ...
>> RETURN VALUES
>> The putenv() functions returns a non-zero value if it was
>> unable to obtain enough space using malloc(3C) for an
>> expanded environment. Otherwise, 0 is returned.
>> ...
I wrote and ran this little test program:
% cat putenv.c
#include <stdio.h>
#include <stdlib.h>
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
#endif
#if !defined(MAXBIG)
#define MAXBIG (size_t)(50 * 1024 * 1024)
#endif
int
main(void)
{
int ret;
char *big;
ret = putenv("foo");
if (ret != 0) printf("putenv(\"foo\") returns %d\n", ret);
ret = putenv("foobar=foobar");
if (ret != 0) printf("putenv(\"foobar=foobar\") returns %d\n", ret);
big = (char*)malloc(MAXBIG);
if (big != (char*)NULL)
{
memset(big,'X',MAXBIG);
memcpy(big,"x=",2);
big[MAXBIG-1] = '\0';
ret = putenv(big);
if (ret != 0) printf("putenv(\"x=XXX...\") returns %d\n", ret);
}
return (EXIT_SUCCESS);
}
% cc -g putenv.c && ./a.out
[no output]
Even with -DMAXBIG='500 * 1024 * 1024', it did not produce an error.
I tried it on some other systems with 500MB and 1GB strings: the a.out
file took a long time to run, but did not report an error. Thus, it
doesn't look like a nonzero return from putenv() is likely.
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- Center for Scientific Computing FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah Internet e-mail: address@hidden -
- Department of Mathematics, 110 LCB address@hidden address@hidden -
- 155 S 1400 E RM 233 address@hidden -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe -
-------------------------------------------------------------------------------
--- End Message ---