It is hard to tell what really happens from your description and the small code chunk.
However, the attempts to change buffering before execv
will have no effect, as the process will be replaced as a whole, including libc stdio state. You need to change buffering in the executed child process instead.
If you don't control the child, then you can execute it with stdbuf
.