getenv("LOGNAME") is incorrect when a child create a shell which call parent
The command line interface parent process (CLI) fork and its child create a shell which then create a new process for CLI (we call it CLI2).
Inside CLI2, the getenv("LOGNAME") value is incorrect. Is it because getenv is not reentrant? getenv_r is not supported on the linux I used. How to ensure inside CLI2 the environment value of getenv("LOGNAME") value of CLI is right? This is an old program which I maintained. |
What output do you get when you run this program?
Code:
#include <sys/types.h> |
Quote:
$ a.out In parent process, LOGNAME is powah. About to spawn a new process. Should I continue? y In child process, LOGNAME is powah. |
Ok. So my sample program does exactly what you say your program does, and my sample program shows that environment variable LOGNAME remains in the child process.
But your program doesn't behave that way. So your job is to figure out why my program works in this regard and yours doesn't. Good luck. |
All times are GMT -5. The time now is 11:32 AM. |