Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site ihdev.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!ihdev!pdg From: pdg@ihdev.UUCP (P. D. Guthrie) Newsgroups: net.lang.c Subject: Re: setenv from c Message-ID: <324@ihdev.UUCP> Date: Wed, 25-Sep-85 10:03:16 EDT Article-I.D.: ihdev.324 Posted: Wed Sep 25 10:03:16 1985 Date-Received: Fri, 27-Sep-85 03:11:24 EDT References: <2936@ncsu.UUCP> <196@mips.UUCP> Reply-To: pdg@ihdev.UUCP (55224-P. D. Guthrie) Organization: AT&T Bell Laboratories Lines: 33 >Rick Johnson (decvax!mcnc!ncsu!rlj) writes: >> Is it possible to set a csh environment variable within a C program? I know >> about getenv(), but have failed at attempts to set an environment variable >> from a C program. Basically, what I want to do is "source" a new environment >> variable for the current csh process. Any comments or suggestions would be >> appreciated. Thanks. > >A process cannot modify its parent's environment, on purpose. At one point, >such a feature was considered, and rejected, because it had no simple, >understandable semantics. For example, many otherwise deterministic >computations turn nondeterministic, depending on process scheduling. >Consider a pipeline like a | b | c, where all of a, b, c could modify >their parent's environment, or worse, nohup a& (and logoff). [Exactly >what is a modifying?] >-- >-john mashey >UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!mash >DDD: 415-960-1200 >USPS: MIPS Computer Systems, 1330 Charleston Rd, Mtn View, CA 94043 What about implementing some type of library function and corresponding shell commands that would load and save an "environment", including perhaps aliases, sort of like Carnegie-Mellon's PCL-Exec for Tops-20. This would enable someone to modify the environment from a program and then have the shell load it in, so file locking could be used to guard against multiple modifications. I guess this capability crudely exists with the source command, but I was thinking of something at a lower level with less command interpretation. I really liked PCL-Exec, and something with that power would be great on Unix. Perhaps a signal could be used to notify a process that it has a new environment? Paul Guthrie.