Index: sys/kern/sys_pipe.c =================================================================== --- sys/kern/sys_pipe.c (revision 228073) +++ sys/kern/sys_pipe.c (working copy) @@ -569,12 +569,6 @@ /* If we're not backing this pipe, no need to do anything. */ error = 0; } - if (error == 0) { - pipe->pipe_ino = alloc_unr(pipeino_unr); - if (pipe->pipe_ino == -1) - /* pipeclose will clear allocated kva */ - error = ENOMEM; - } return (error); } @@ -1399,6 +1393,7 @@ struct thread *td; { struct pipe *pipe = fp->f_data; + int new_unr; #ifdef MAC int error; @@ -1408,6 +1403,12 @@ if (error) return (error); #endif + if (pipe->pipe_ino == 0) { + new_unr = alloc_unr(pipeino_unr); + if (new_unr == -1) + return (ENOMEM); + pipe->pipe_ino = new_unr; + } bzero(ub, sizeof(*ub)); ub->st_mode = S_IFIFO; ub->st_blksize = PAGE_SIZE; @@ -1554,7 +1555,7 @@ } else PIPE_UNLOCK(cpipe); - if (ino > 0) + if (ino != 0) free_unr(pipeino_unr, cpipe->pipe_ino); }