Here are some misc tips about programming in C.
Correctly dealing with interactive subprocesses in Unix works best by using pseudo terminals. See here for details.