Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: $Revision: 1.6.2.16 $; site mirror.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!mirror!rs From: rs@mirror.UUCP Newsgroups: net.lang.c Subject: Re: setenv from c Message-ID: <6000007@mirror.UUCP> Date: Wed, 25-Sep-85 10:34:00 EDT Article-I.D.: mirror.6000007 Posted: Wed Sep 25 10:34:00 1985 Date-Received: Sat, 28-Sep-85 07:46:23 EDT References: <2936@ncsu.UUCP> Lines: 33 Nf-ID: #R:ncsu:-293600:mirror:6000007:000:968 Nf-From: mirror!rs Sep 25 10:34:00 1985 > Is it possible to set a csh environment variable within a C program? Presumably you want to do something like the BSD "tset" program, which SEEMS LIKE it adds environment variables to its parent's process. The only way to do this is to have your program write out a command line that can be "sourced" in. For example, this program: main() { int p; if (p = fork()) printf("setenv CLOCKPID %d ; echo clock...", p), exit(0); ...print a clock on the status line every once in a while... } You can now add the pid of the clock "daemon" by doing something like this: CSH SH EITHER clock >/tmp/$$ clock >/tmp/$$ eval `clock` source /tmp/$$ . /tmp/$$ rm /tmp/$$ rm /tmp/$$ Note that if your environment variables contain shell meta-characters, you might have problems (only CSH, I think). -- Rich $alz {mit-eddie, ihnp4!inmet, wjh12, cca, datacube} !mirror!rs Mirror Systems 2067 Massachusetts Ave. 617-661-0777 Cambridge, MA, 02140