NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Silly shell question



On Tue, 22 Mar 2016, Swift Griggs wrote:

> On Tue, 22 Mar 2016, Johnny Billquist wrote:
> > Only environment variables are propagated to child processes.
> 
> Thanks for the info, but do you happen to know what the actual 
> mechanism that the child processes is able to "import" the exported 
> variable ? Ie.. is it some special OS glue/magic, or is it just 
> straight getenv() calls by the client shell/app ?

Yes just use getenv. See the manpage. I wouldn't call it a "client" but 
either a child or replacement.

> I don't see anything magical in the man page for getenv() that would 
> distinguish an exported versus non-exported variable.

The concept doesn't exist at that level. Have a look at the execve 
manpage.  Also have a look at the src/bin/sh source too:

execcmd in eval.c
environment in var.c
tryexec in exec.c


Home | Main Index | Thread Index | Old Index