Why close pipe in c? -
what go wrong if reader of pipe forgets close fd[1] or if writer of pipe forgets close fd[0]?
you'll have file handle leak (as long process has file descriptor open running). worst thing can happen run out of file descriptor handles if have lot of pipes.
there's soft , hard limit (see ulimit
) per user, , system wide limit (although you're unlikely hit if system has useful per-user limit). once run out of file descriptor handles, strange things happen won't able start new processes or other running processes might stop working correctly.
most of time isn't worry of time there's 2 processes , 1 pipe, leak won't big deal. still, want close filehandle don't need more free resources.
Comments
Post a Comment