projects
/
libc-test
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b950224
)
fix t_fdfill so it does not use much kernel side resources
author
Szabolcs Nagy
<nsz@port70.net>
Sat, 20 Jul 2013 21:05:07 +0000
(21:05 +0000)
committer
Szabolcs Nagy
<nsz@port70.net>
Sat, 20 Jul 2013 21:05:07 +0000
(21:05 +0000)
src/common/fdfill.c
patch
|
blob
|
history
diff --git
a/src/common/fdfill.c
b/src/common/fdfill.c
index
da744c1
..
6419e93
100644
(file)
--- a/
src/common/fdfill.c
+++ b/
src/common/fdfill.c
@@
-1,9
+1,15
@@
+#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
+#include <errno.h>
#include "test.h"
void t_fdfill(void)
{
#include "test.h"
void t_fdfill(void)
{
- int fd[2];
- while (pipe(fd) == 0);
- dup(0);
+ int fd = 1;
+ if (dup(fd) == -1) {
+ if (errno == EMFILE)
+ return;
+ fd = open("/dev/null", O_RDONLY);
+ }
+ while(dup(fd) != -1);
}
}