Fossil SCM

Another attempt to fix the harmless compiler warning in popen2().

drh 2024-02-06 14:07 trunk
Commit b1483634c6284812e16127294e569c2dcf7efaa4418d5bc69447a0c02230f994
1 file changed +3 -1
+3 -1
--- src/popen.c
+++ src/popen.c
@@ -198,11 +198,13 @@
198198
close(1);
199199
fd = dup(pin[1]);
200200
if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1");
201201
close(pin[0]);
202202
close(pin[1]);
203
- close(2); (void)dup(1); /* Redirect stderr into the stdout pipe */
203
+ close(2);
204
+ fd = dup(1);
205
+ if( fd!=2 ) fossil_panic("popen() failed to redirect stderr into stdout");
204206
if( bDirect ){
205207
execl(zCmd, zCmd, (char*)0);
206208
}else{
207209
execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
208210
}
209211
--- src/popen.c
+++ src/popen.c
@@ -198,11 +198,13 @@
198 close(1);
199 fd = dup(pin[1]);
200 if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1");
201 close(pin[0]);
202 close(pin[1]);
203 close(2); (void)dup(1); /* Redirect stderr into the stdout pipe */
 
 
204 if( bDirect ){
205 execl(zCmd, zCmd, (char*)0);
206 }else{
207 execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
208 }
209
--- src/popen.c
+++ src/popen.c
@@ -198,11 +198,13 @@
198 close(1);
199 fd = dup(pin[1]);
200 if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1");
201 close(pin[0]);
202 close(pin[1]);
203 close(2);
204 fd = dup(1);
205 if( fd!=2 ) fossil_panic("popen() failed to redirect stderr into stdout");
206 if( bDirect ){
207 execl(zCmd, zCmd, (char*)0);
208 }else{
209 execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0);
210 }
211

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button