c - program not executing anything after a call to system() -
i calling command via system(command) call. no other code executed after system() call.
why so? thought, system() create child process "command" execution , program (parent of "command"-child) continue executing code after that.
am not understanding system() correctly?
code:
printf("before \n"); system("tail -f filename"); /* long lived - never returns */ printf("after \n");
here, not see after getting printed ever.
the system(3)
function causes process wait completion of child.
edit 0:
you have use classic pair of fork(2)
, execve(2)
want do. might check whether c library provides posix spawn(3)
.
edit 1:
look waitpid(2)
keep parent around.
Comments
Post a Comment