@@ -63,11 +63,21 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
6363 if (ffPipe2 (pipes , O_CLOEXEC ) == -1 )
6464 return "pipe() failed" ;
6565
66+ pid_t childPid = -1 ;
67+ int nullFile = ffGetNullFD ();
68+
69+ #if !(__ANDROID__ || __OpenBSD__ )
70+
71+ // NetBSD / Darwin: native syscall
72+ // Linux (glibc): clone3-execve
73+ // FreeBSD: vfork-execve
74+ // illumos: vforkx-execve
75+ // OpenBSD / Android (bionic): fork-execve
76+
6677 posix_spawn_file_actions_t file_actions ;
6778 posix_spawn_file_actions_init (& file_actions );
6879 posix_spawn_file_actions_adddup2 (& file_actions , pipes [1 ], useStdErr ? STDERR_FILENO : STDOUT_FILENO );
69- posix_spawn_file_actions_addopen (& file_actions , useStdErr ? STDOUT_FILENO : STDERR_FILENO , "/dev/null" , O_WRONLY , 0 );
70- pid_t childPid = -1 ;
80+ posix_spawn_file_actions_adddup2 (& file_actions , nullFile , useStdErr ? STDOUT_FILENO : STDERR_FILENO );
7181
7282 static char * oldLang = NULL ;
7383 static int langIndex = -1 ;
@@ -113,13 +123,38 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
113123
114124 posix_spawn_file_actions_destroy (& file_actions );
115125
116- close (pipes [1 ]);
117126 if (ret != 0 )
118127 {
119128 close (pipes [0 ]);
129+ close (pipes [1 ]);
120130 return "posix_spawnp() failed" ;
121131 }
122132
133+ #else
134+
135+ // https://github.com/termux/termux-packages/issues/25369
136+ childPid = fork ();
137+ if (childPid == -1 )
138+ {
139+ close (pipes [0 ]);
140+ close (pipes [1 ]);
141+ return "fork() failed" ;
142+ }
143+
144+ if (childPid == 0 )
145+ {
146+ //Child
147+ dup2 (pipes [1 ], useStdErr ? STDERR_FILENO : STDOUT_FILENO );
148+ dup2 (nullFile , useStdErr ? STDOUT_FILENO : STDERR_FILENO );
149+ putenv ("LANG=C.UTF-8" );
150+ execvp (argv [0 ], argv );
151+ _exit (127 );
152+ }
153+
154+ #endif
155+
156+ close (pipes [1 ]);
157+
123158 int FF_AUTO_CLOSE_FD childPipeFd = pipes [0 ];
124159 char str [FF_PIPE_BUFSIZ ];
125160
0 commit comments