diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2006-02-28 18:21:33 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2006-02-28 18:21:33 +0000 |
commit | 050e82e0884b3291580547eada1d9ddc78fed423 (patch) | |
tree | b4b15d55020d9719fe5bd8564c93885bcb86ec9a | |
parent | 88377e5b61d3b776d13fb93ae77462772f1daebf (diff) |
Don't lock up at start when there aren't any free file descriptors.
-rw-r--r-- | src/main.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c index 88282a01d..aca7aa3f6 100644 --- a/src/main.c +++ b/src/main.c @@ -4279,8 +4279,11 @@ quit_curl: return res; } -static void checkfds(void); - +/* Ensure that file descriptors 0, 1 and 2 (stdin, stdout, stderr) are + open before starting to run. Otherwise, the first three network + sockets opened by curl could be used for input sources, downloaded data + or error logs as they will effectively be stdin, stdout and/or stderr. +*/ static void checkfds(void) { #ifdef HAVE_PIPE @@ -4291,8 +4294,9 @@ static void checkfds(void) fd[1] == STDIN_FILENO || fd[1] == STDOUT_FILENO || fd[1] == STDERR_FILENO ) - pipe(fd); - + if (pipe(fd) < 0) + return; /* Out of handles. This isn't really a big problem now, but + will be when we try to create a socket later. */ close(fd[0]); close(fd[1]); #endif |