From 61fb9bd80c721bf26694235d79f325c8df0191c2 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 30 Jan 2006 08:25:04 +0000 Subject: [PATCH] - In pipe() return the error returned by pipe_create(), rather then hardcoded ENFILES, which is incorrect. pipe_create() can fail due to ENOMEM. - Update manual page, describing ENOMEM return code. Reviewed by: arch --- lib/libc/sys/pipe.2 | 4 +++- sys/kern/sys_pipe.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2 index 247b9990a52..5f5ac3a1fbe 100644 --- a/lib/libc/sys/pipe.2 +++ b/lib/libc/sys/pipe.2 @@ -32,7 +32,7 @@ .\" @(#)pipe.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd January 30, 2006 .Dt PIPE 2 .Os .Sh NAME @@ -98,6 +98,8 @@ system call will fail if: Too many descriptors are active. .It Bq Er ENFILE The system file table is full. +.It Bq Er ENOMEM +Not enough kernel memory to establish a pipe. .It Bq Er EFAULT The .Fa fildes diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index a237d979408..3b631988d4b 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -357,10 +357,11 @@ pipe(td, uap) NULL); /* Only the forward direction pipe is backed by default */ - if (pipe_create(rpipe, 1) || pipe_create(wpipe, 0)) { + if ((error = pipe_create(rpipe, 1)) != 0 || + (error = pipe_create(wpipe, 0)) != 0) { pipeclose(rpipe); pipeclose(wpipe); - return (ENFILE); + return (error); } rpipe->pipe_state |= PIPE_DIRECTOK;