int main(int argc, char **argv) { setup_readline(); struct Environment *env = new_standard_environment(); bool success = process_args(argc, argv, env); release_environment(env); return success ? 0 : 1; }
/** This function takes the environment variables set up in the * source process and duplicates (copies) everything across to the * destination process. * * \warning This function first calls release_environment on the * destination process. Also, if an error occurs during the clone * then the destination process is left without any environment * variables. * * \param src The R-LOCKED source process to get environment variables from. * \param dest The W-LOCKED dest process to copy environment variables into. * \return 0 on success. */ int clone_environment( struct process *dest, struct process *src ) { int i; struct environ_info *env = (struct environ_info *)src->environment; if ( release_environment( dest ) != 0 ) return -1; if ( env == NULL ) return 0; // Already done. :) for ( i = 0; i < src->environment_count; i++ ) { if ( set_environment( dest, env[i].name, env[i].data, env[i].size ) != 0 ) { release_environment( dest ); return -1; } } return 0; }