int main(int argc, char * argv[], char * envp[]) {
string varName = "variable name to find"
i = 0;
string env;
found = false;
while (envp[i] != nullptr and not found) {
env = envp[i];
pos = env.find("=");
if (env.substr(0,pos) == varName) {
// code to take action here.
found = true;
}
i++;
}
}
string varName = "variable name to find"
char * value;
value = getenv(varName.c_str());
if (value!= nullptr) {
// code to take action here.
}
pid_t waitpid(pid_t pid, int *wstatus, int options);
int fd[2]; pipe(fd); if (0==fork()) { // writer close(fd[read]) for(1;i<=10;i++) { write(fd[write], &i, sizeof(i); } exit(0); } else { close(fd[write]) while (read(fd[read],&num, sizeof(num)) != 0) { cout << num << endl; } exit(0); }
pipe fork if child write if parent read