execve(“/bin/sh”, 0, 0); in a pipe
I have the following example program: #include <stdio.h> int main(int argc, char ** argv){ char buf[100]; printf("Please enter your name: "); fflush(stdout); gets(buf); printf("Hello \"%s\"\n", buf); execve("/bin/sh", 0, 0); } I and when I run without any pipe it works as it should and returns a sh promt: bash$ ./a.out Please enter your name: warning: this program uses gets() which is unsafe. testName Hello "testName" $ exit bash$ But this does not work in a pipe, i think I know why that is, but I cannot figure out a solution. Example run bellow. bash$ echo -e "testName\npwd" | ./a.out Please