Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: How do I ex...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 10 Topic 26133 of 26972
Post > Topic >>

Re: How do I ex****t a environmental variable to a C program?

by Keith Thompson <kst-u@[EMAIL PROTECTED] > May 9, 2008 at 11:52 AM

jt@[EMAIL PROTECTED]
 (Jens Thoms Toerring) writes:
> iavian <vijay@[EMAIL PROTECTED]
> wrote:
>> I want to set a env variable in a C program? . Not through shell env
>> variables. Any help?
>
> This is not a C question since this only depends on how your
> shell handles things. But, that out of the way, you simply
> can't do that (at least with no shell I ever heard of). Your
> C program is a process started by your shell and such a child-
> process can never change anything in its "parent" process.

The OP didn't seem to be asking about propagating the setting to the
parent process (assuming that "parent process" is meaningful).  As far
as I can tell, the POSIX setenv() function (not standard C) would
satisfy the requirement he stated.  Whether it would satisfy his
actual requirement is another question.

<OT>In Unix-like systems, there are various ways for a process to set
one of its own environment variables in response to information from a
child process.  You demonstrated one of them in part of your article
that I ruthlessly snipped; other ways are possible.
comp.unix.programmer would be a better place to discuss it -- after
checking any FAQ lists, since this kind of question comes up
frequently.</OT>

-- 
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
 




 10 Posts in Topic:
How do I export a environmental variable to a C program?
iavian <vijay@[EMAIL P  2008-05-09 10:26:48 
Re: How do I export a environmental variable to a C program?
Antoninus Twink <nospa  2008-05-09 19:37:30 
Re: How do I export a environmental variable to a C program?
dj3vande@[EMAIL PROTECTED  2008-05-09 17:34:38 
Re: How do I export a environmental variable to a C program?
roberson@[EMAIL PROTECTED  2008-05-09 17:44:55 
Re: How do I export a environmental variable to a C program?
jt@[EMAIL PROTECTED] (Je  2008-05-09 17:45:19 
Re: How do I export a environmental variable to a C program?
Keith Thompson <kst-u@  2008-05-09 11:52:25 
Re: How do I export a environmental variable to a C program?
iavian <vijay@[EMAIL P  2008-05-10 18:22:13 
Re: How do I export a environmental variable to a C program?
Keith Thompson <kst-u@  2008-05-10 20:25:39 
Re: How do I export a environmental variable to a C program?
CBFalconer <cbfalconer  2008-05-10 22:53:25 
Re: How do I export a environmental variable to a C program?
Jack Klein <jackklein@  2008-05-10 22:39:04 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:40:05 CDT 2008.