pipe() not setting errno.
Hello,
When running out of file descriptors pipe() does return -1 but errno is not set. This is working ok on IA32 systems, but fails on IA64. I've tested this with kernels 2.4.9 and 2.4.18.
Below is a small sample program to illustrate the problem:
########################################################
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
int main (int argc, char **argv){
int i;
for (i = 0; i < 3000; i++) {
int fd[2];
if (-1 = pipe(fd))
break;
printf ("%d ", i); } /* for */
printf ("\npipe number %d error: errno=%d\n", i, errno); return errno;
}
#############################################################
Sample run:
$ ulimit -n 12 $ ./tpipe 0 1 2 3 pipe number 4 error: errno=0
Regards
Anders Herbjørnsen
Anders Herbjørnsen <[email protected]> writes:
|> Hello, |> |> When running out of file descriptors pipe() does return -1 but |> errno is not set. This is working ok on IA32 systems, but fails |> on IA64. I've tested this with kernels 2.4.9 and 2.4.18.
It's a bug in glibc, this should fix it:
2002-04-04 Andreas Schwab <[email protected]>
* sysdeps/unix/sysv/linux/ia64/pipe.S: Don't overwrite r8 on error.
unix/sysv/linux/ia64/pipe.S renamed from unix/sysv/linux/ia64/pipe.S.~1.2.~ +2 -2
@@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger <[email protected]>
@@ -28,7 +28,7 @@ cmp.ne p6,p0=-1,r10 ;; (p6) st4 [r2]=r8,4 - mov ret0=0 +(p6) mov ret0=0 ;; (p6) st4 [r2]=r9 (p6) ret
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Reply to the message of Thursday April 4, 2002 15:36 +0100
-----------------------------------------------------------------
Andreas Schwab <[email protected] internet> writes:
|> When running out of file descriptors pipe() does return -1 but |> errno is not set. This is working ok on IA32 systems, but fails |> on IA64. I've tested this with kernels 2.4.9 and 2.4.18.
Quoted 1 line
It's a bug in glibc, this should fix it:
Thanks, the patch worked like charm!
Anders
Ulrich Drepper
AppliedQuoted 4 lines · Andreas Schwab
2002-04-04 Andreas Schwab <[email protected]>
*
sysdeps/unix/sysv/linux/ia64/pipe.S: Don't overwrite r8 on error.
I've applied the patch now. Thanks,
Signature · 3 lines
---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------