I get an output of "hi!". Why is this not also printing "something"?
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv) {
char* program_name = "echo";
char* args[]= {program_name,"hi!",NULL};
printf("something");
execvp(program_name,args);
return 0;
}
I know I'm not creating a child process first. If I take out the execvp line, it works as expected. Weird. (Note: "echo" refers to https://en.wikipedia.org/wiki/Echo_(command))
The string is in the io buffer - so pull the chain and flush that buffer
i.e. add
after the
printf
(or add\n
to theprintf
)