More questions about how to issue a C-SHELL command within a C program

Frank P. Bresz fpb at ittc.wec.com
Thu Aug 16 14:48:55 AEST 1990


In article <1990Aug15.221504.348 at iwarp.intel.com> merlyn at iwarp.intel.com (Randal Schwartz) writes:
>In article <25285.26c9113d at kuhub.cc.ukans.edu>, jian at kuhub writes:

	[ Stuff deleted ]

>|         execlp("/bin/csh", "csh", "-c", "setenv TERM adm3a", (char *) 0);
>| 
>| There was not any runtime errors if I embeded one of above statements into my
>| C program. But none of them can change the terminal type. I don't know why.
>| Would someone point me another way to change terminal type within a C program
>| or give me some hints what I did wrong. I would appreciate any helps.

>The short answer:

>You *cannot* change an environment variable (such as TERM) from a
>child process.  The shell provides a *copy* of its environment to the
>children processes (such as your C program), so changes to that copy
>(or in your case, using a further csh which has its *own* copy), will
>not affect the parent shell.  This is by design, so don't ask "Well,
>are they going to fix this some day?"

	Why not just use the putenv system call with something akin to:

putenv("TERM=adm3a");	/* notify subprocess that it is an adm3a terminal */


--
+--------------------+
|fbresz at ittc.wec.com |  My opinions are my own, I'm not paid
|uunet!ittc!fbresz   |  enough to make an official statement  
|(412)733-6749       |  +-----------------------------------+
|Fax: (412)733-6444  |  |      THIS SPACE FOR SALE!!!       |
+--------------------+  +-----------------------------------+



More information about the Comp.unix.questions mailing list