Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix return code for pipe(2) syscall


  sometimes pipe(2) can return ENFILE, which has nothing to do
with number of open files. It happens when we run out of kva.

However, pipe(2) can also return correct ENFILE, when falloc()

  The only way to distinguish between latter error and the
former one is looking into the 'dmesg' output, right after
failure. If your dmesg is later overwritten with some other
logging, then you will loose this information, and you won't
be able to tell why pipe(2) syscall yesterday returned ENFILE -
did it hit descriptor limit or kva?

Recently I've got some communication with people, who have
problems with mpd port. They have experienced ENFILE from
pipe(2). They have spent some time tuning descriptor limits
and I spent some time trying to help them, until we looked
into dmesg, and then into source, to discover alternative
meaning of ENFILES.

Any objection for the attached change? It should make return
ENOMEM in case of kva outage?

Yes, according to SUSv3 the only errors from pipe(2) are ENFILE
and EMFILE. I think that blindly following standard in this
case will lead to confusion (see above). And we already return
EFAULT from pipe(2), which is not described in standard.

Totus tuus, Glebius.
Index: sys_pipe.c
RCS file: /home/ncvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.185
diff -u -r1.185 sys_pipe.c
--- sys_pipe.c	16 Dec 2005 18:32:39 -0000	1.185
+++ sys_pipe.c	27 Jan 2006 09:15:56 -0000
@@ -357,10 +357,11 @@
 	/* 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) {
-		return (ENFILE);
+		return (error);
 	rpipe->pipe_state |= PIPE_DIRECTOK;
freebsd-arch@xxxxxxxxxxx mailing list
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"