This preview shows page 1. Sign up to view the full content.
Unformatted text preview: w program starts. are the argument and environment strings, which are stored contiguously on the stack, one after the other without any gaps. These are followed further up the stack by a null-terminated array of pointers, each of which points to an environment variable string on the stack. The global variable environ points to the ﬁrst of these pointers, envp. The environment array is followed immediately by the null-terminated argv array, with each element pointing to an argument string on the stack. At the top of the stack are the three arguments to the main routine: (1) envp, which points the envp array, (2) argv, which points to the argv array, and (3) argc, which gives the number of non-null pointers in the argv array. Unix provides several functions for manipulating the environment array. 8.4. PROCESS CONTROL
#include <stdlib.h> char *getenv(const char *name); 417 returns: ptr to name if exists, NULL if no match. The getenv function searches the environment array for a stri...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American