← Commit list

0ebe0e9785

Stefan Eissing
Stefan Eissing
2026-08-28
SUCCESS Duration: 413s

Subject

tool: checkfds, open on null device

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_main.c+18 -9
@@ -73,7 +73,6 @@ int _CRT_glob = 0;
/* if we build a static library for unit tests, there is no main() function */
#ifndef UNITTESTS
-#if defined(HAVE_PIPE) && defined(HAVE_FCNTL)
/*
* Ensure that file descriptors 0, 1 and 2 (stdin, stdout, stderr) are
* open before starting to run. Otherwise, the first three network
@@ -86,17 +85,27 @@ int _CRT_glob = 0;
*/
static int main_checkfds(void)
{
- int fd[2];
- while((fcntl(STDIN_FILENO, F_GETFD) == -1) ||
- (fcntl(STDOUT_FILENO, F_GETFD) == -1) ||
- (fcntl(STDERR_FILENO, F_GETFD) == -1))
- if(pipe(fd))
+#if defined(HAVE_FCNTL) && defined(HAVE_PIPE)
+ const char * const devnull = "/dev/null";
+ int fd;
+ while((fcntl(STDIN_FILENO, F_GETFD) == -1)) {
+ fd = curlx_open(devnull, O_RDONLY);
+ if(fd < 0)
return 1;
+ }
+ while((fcntl(STDOUT_FILENO, F_GETFD) == -1)) {
+ fd = curlx_open(devnull, O_WRONLY);
+ if(fd < 0)
+ return 1;
+ }
+ while((fcntl(STDERR_FILENO, F_GETFD) == -1)) {
+ fd = curlx_open(devnull, O_WRONLY);
+ if(fd < 0)
+ return 1;
+ }
+#endif /* HAVE_FCNTL && HAVE_PIPE */
return 0;
}
-#else
-#define main_checkfds() 0
-#endif
#ifdef CURL_MEMDEBUG
static void memory_tracking_init(void)