I've had a look through the code but I have no idea. Try outputting debug messages indicating clearly what's going on, to a file, one for the forked process and one for the parent. Don't forget that after calling fork() BOTH processes continue to execute simultaneously, and as you don't wait for the child process to end it could be that the parent does something to disrupt the child processes (e.g. close(fd_server) might be a problem if it happens half way through the operation). Race conditions are very hard to debug and as you have no synchronisation that's what I suspect you have. Or a memory corruption, hence the commend about curdir.