Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site talcott.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!talcott!tmb From: tmb@talcott.UUCP (Thomas M. Breuel) Newsgroups: net.lang.c Subject: Re: setenv from c Message-ID: <517@talcott.UUCP> Date: Sat, 28-Sep-85 22:26:52 EDT Article-I.D.: talcott.517 Posted: Sat Sep 28 22:26:52 1985 Date-Received: Wed, 2-Oct-85 00:24:09 EDT References: <2936@ncsu.UUCP> <6000007@mirror.UUCP> <1355@teddy.UUCP> Organization: Harvard University Lines: 16 In article <1355@teddy.UUCP>, jpn@teddy.UUCP writes: > > Is it possible to set a csh environment variable within a C program? > > In all the replies to this question, I have not yet seen my favorite techniqe > This only works on BSD 4.X (at least as far as I know). There is an > undocumented ioctl() which allows you to push data back onto your input queue > (i.e. simulate characters typed at the terminal). Using this technique, one > can stuff strings like "setenv TERM xxx\n" into the parent shell's input. The ioctl is documented in tty(4). Generally, your program is unlikely to be smart enough to type at whatever I invoke it from (e.g. shell escape from ed). Use of this ioctl can cause extremely weird behaviour of programs and shell scripts. Since it is also non-portable, works only on ttys and might be abolished altogether, I would strongly recommend *not* to use it. Thomas.