1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-15 07:54:13 +00:00

Replace calls to putenv with setenv (#99)

* Use setenv instead of putenv

* Replace sprintf with snprintf

* unixfork.c: Stack allocate tempstring
This commit is contained in:
Javier Olaechea 2020-12-19 22:51:41 -05:00 committed by GitHub
parent 6fb4b9a189
commit ecaf50c015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,11 +144,10 @@ int ForkUnixShell(int slot, char ltr, char numb, char *termtype, char *shellarg)
/* set the LDESHELL variable so the underlying .cshrc can see it and
configure the shell appropriately, though this may not be so important any more */
putenv("LDESHELL=YES");
setenv("LDESHELL", "YES", 1);
if ((termtype[0] != 0) && (strlen(termtype) < 59)) { /* set the TERM environment var */
sprintf(envstring, "TERM=%s", termtype);
putenv(envstring);
setenv("TERM", termtype, 1);
}
/* Start up csh */
argvec[0] = "csh";
@ -269,23 +268,19 @@ int fork_Unix() {
and put their numbers in the environment so parent can find them */
/* JDS - NB that sprintf doesn't always return a string! */
char *tempstring;
char tempstring[30];
tempstring = (char *)malloc(30);
sprintf(tempstring, "LDEPIPEIN=%d", UnixToLisp[0]);
putenv(tempstring);
snprintf(tempstring, sizeof(tempstring), "%d", UnixToLisp[0]);
setenv("LDEPIPEINE", tempstring, 1);
tempstring = (char *)malloc(30);
sprintf(tempstring, "LDEPIPEOUT=%d", LispToUnix[1]);
putenv(tempstring);
snprintf(tempstring, sizeof(tempstring), "%d", LispToUnix[1]);
setenv("LDEPIPEOUT", tempstring, 1);
tempstring = (char *)malloc(30);
sprintf(tempstring, "LDESTARTTIME=%ld", StartTime);
putenv(tempstring);
snprintf(tempstring, sizeof(tempstring), "%ld", StartTime);
setenv("LDESTARTTIME", tempstring, 1);
tempstring = (char *)malloc(30);
sprintf(tempstring, "LDEUNIXPID=%d", UnixPID);
putenv(tempstring);
snprintf(tempstring, sizeof(tempstring), "%d", UnixPID);
setenv("LDEUNIXPID", tempstring, 1);
close(LispToUnix[0]);
close(UnixToLisp[1]);