@@ -63,11 +63,21 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
63
63
if (ffPipe2 (pipes , O_CLOEXEC ) == -1 )
64
64
return "pipe() failed" ;
65
65
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
+
66
77
posix_spawn_file_actions_t file_actions ;
67
78
posix_spawn_file_actions_init (& file_actions );
68
79
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 );
71
81
72
82
static char * oldLang = NULL ;
73
83
static int langIndex = -1 ;
@@ -113,13 +123,38 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
113
123
114
124
posix_spawn_file_actions_destroy (& file_actions );
115
125
116
- close (pipes [1 ]);
117
126
if (ret != 0 )
118
127
{
119
128
close (pipes [0 ]);
129
+ close (pipes [1 ]);
120
130
return "posix_spawnp() failed" ;
121
131
}
122
132
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
+
123
158
int FF_AUTO_CLOSE_FD childPipeFd = pipes [0 ];
124
159
char str [FF_PIPE_BUFSIZ ];
125
160
0 commit comments