Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!ittc!fpb From: fpb@ittc.wec.com (Frank P. Bresz) Newsgroups: comp.unix.questions Subject: Re: More questions about how to issue a C-SHELL command within a C program Message-ID: Date: 16 Aug 90 04:48:55 GMT References: <25285.26c9113d@kuhub.cc.ukans.edu> <1990Aug15.221504.348@iwarp.intel.com> Sender: news@ittc.wec.com Reply-To: fbresz@ittc.wec.com Organization: Westinghouse, ITTC, Pgh, PA. Lines: 34 In-reply-to: merlyn@iwarp.intel.com's message of 15 Aug 90 22:15:04 GMT In article <1990Aug15.221504.348@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: >In article <25285.26c9113d@kuhub.cc.ukans.edu>, jian@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@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!!! | +--------------------+ +-----------------------------------+