Skip to content

Instantly share code, notes, and snippets.

@btbytes
Last active August 3, 2017 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btbytes/0b8025c710aa8447343cc86a1fbd84bb to your computer and use it in GitHub Desktop.
Save btbytes/0b8025c710aa8447343cc86a1fbd84bb to your computer and use it in GitHub Desktop.
/*
on Unix the 'main' function in C can also take a 3rd argument, a pointer to the current environment variables.
https://www.gnu.org/software/libc/manual/html_node/Program-Arguments.html
Via: https://twitter.com/deech/status/892938689927630848
gcc envp.c -o prog
*/
#include <stdio.h>
int main(int argc, char *argv[], char *envp[])
{
for (size_t i = 0; i < sizeof(envp); i++)
{
printf("%s\n", envp[i]);
}
}
AWS_HOME=/Users/pgowda/.aws
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.V28Aqn6H4u/Render
CAML_LD_LIBRARY_PATH=/Users/pgowda/.opam/4.02.3/lib/stublibs
DBUS_LAUNCHD_SESSION_BUS_SOCKET=/private/tmp/com.apple.launchd.TyY5jooP1f/unix_domain_listener
DISPLAY=/private/tmp/com.apple.launchd.TfvbOMunNM/org.macosforge.xquartz:0
GEM_HOME=/Users/pgowda/.rvm/gems/ruby-2.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment