Problem when use getc function before creating a new process with execve()
I am facing a strange problem.
I am using execve() to run a program with new enviornment variables.
before I call execve(), I have to read an input from the user.
When the user types the input, and i read it in my code using gets(); my program works fine, and execve calls other executable as expected.
But if instead of gets() I read user input using getc(), as in
*(pDisp + iCnt++) = getc(stdin);
}while(*(pDisp + (iCnt - 1))!='\n');
then when execve() function is encountered in the code,
It does nothing, it does not call my other executable code.
Any hints ?
My C is a bit rusty, but I believe gets() will terminate its output with a null character. Your loop terminates it with a newline. I am wondering if this input is used to set up the environment variables for the execve() call and the lack of a null character is tripping things up.
|All times are GMT -5. The time now is 11:37 AM.|