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
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