I´m trying to update the PATH variable through a program in c but when i try to update it, it comes the problems. I have tried system("source .profile") and execlp("source", "source", ".profile", NULL) but none of them works, I do not know how to make it run so the PATH get update. Has anybody an idea about this? Thanks.
You can use the setenv function in stdlib.h to set environment variables
The setenv() function adds the variable name to the environment with the value value, if name does not already exist. If name does exist in the environment, then its value is changed to value if overwrite is nonzero; if overwrite is zero, then the value of name is not changed (and setenv() returns a success status). This function makes copies of the strings pointed to by name and value (by contrast with putenv(3)).
The unsetenv() function deletes the variable name from the environment. If name does not exist in the environment, then the function succeeds, and the environment is unchanged.