fix child process write logic