Fossil SCM
Change popen() back to the way it was last week - so that it shows stderr lines on the console rather than consuming them.
Commit
274079a2e19a1489d8d3a8df82df36736236a24ca63a0078b94190b7896e2de0
Parent
46e7855a4e19200…
1 file changed
+3
-10
+3
-10
| --- src/popen.c | ||
| +++ src/popen.c | ||
| @@ -129,18 +129,19 @@ | ||
| 129 | 129 | FILE **ppOut, /* Write to child using this file descriptor */ |
| 130 | 130 | int *pChildPid, /* PID of the child process */ |
| 131 | 131 | int bDirect /* 0: run zCmd as a shell cmd. 1: run directly */ |
| 132 | 132 | ){ |
| 133 | 133 | #ifdef _WIN32 |
| 134 | - HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr; | |
| 134 | + HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr; | |
| 135 | 135 | SECURITY_ATTRIBUTES saAttr; |
| 136 | 136 | DWORD childPid = 0; |
| 137 | 137 | int fd; |
| 138 | 138 | |
| 139 | 139 | saAttr.nLength = sizeof(saAttr); |
| 140 | 140 | saAttr.bInheritHandle = TRUE; |
| 141 | 141 | saAttr.lpSecurityDescriptor = NULL; |
| 142 | + hStderr = GetStdHandle(STD_ERROR_HANDLE); | |
| 142 | 143 | if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){ |
| 143 | 144 | win32_fatal_error("cannot create pipe for stdout"); |
| 144 | 145 | } |
| 145 | 146 | SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE); |
| 146 | 147 | |
| @@ -148,16 +149,11 @@ | ||
| 148 | 149 | win32_fatal_error("cannot create pipe for stdin"); |
| 149 | 150 | } |
| 150 | 151 | SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE); |
| 151 | 152 | |
| 152 | 153 | win32_create_child_process(fossil_utf8_to_unicode(zCmd), |
| 153 | - hStdinRd,hStdoutWr,hStdoutWr,&childPid); | |
| 154 | - /* ^^^^^^^^^ ^^^^^^^^^ | |
| 155 | - ** Send both stdout and stderr to to *ppOut. | |
| 156 | - ** See check-in 857495ec92a521bb (2024-02-06) and earlier for | |
| 157 | - ** an example of how to leave stderr going to console */ | |
| 158 | - | |
| 154 | + hStdinRd, hStdoutWr, hStderr,&childPid); | |
| 159 | 155 | *pChildPid = childPid; |
| 160 | 156 | *pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0); |
| 161 | 157 | fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0); |
| 162 | 158 | *ppOut = _fdopen(fd, "w"); |
| 163 | 159 | CloseHandle(hStdinRd); |
| @@ -198,13 +194,10 @@ | ||
| 198 | 194 | close(1); |
| 199 | 195 | fd = dup(pin[1]); |
| 200 | 196 | if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1"); |
| 201 | 197 | close(pin[0]); |
| 202 | 198 | close(pin[1]); |
| 203 | - close(2); | |
| 204 | - fd = dup(1); | |
| 205 | - if( fd!=2 ) fossil_panic("popen() failed to redirect stderr into stdout"); | |
| 206 | 199 | if( bDirect ){ |
| 207 | 200 | execl(zCmd, zCmd, (char*)0); |
| 208 | 201 | }else{ |
| 209 | 202 | execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0); |
| 210 | 203 | } |
| 211 | 204 |
| --- src/popen.c | |
| +++ src/popen.c | |
| @@ -129,18 +129,19 @@ | |
| 129 | FILE **ppOut, /* Write to child using this file descriptor */ |
| 130 | int *pChildPid, /* PID of the child process */ |
| 131 | int bDirect /* 0: run zCmd as a shell cmd. 1: run directly */ |
| 132 | ){ |
| 133 | #ifdef _WIN32 |
| 134 | HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr; |
| 135 | SECURITY_ATTRIBUTES saAttr; |
| 136 | DWORD childPid = 0; |
| 137 | int fd; |
| 138 | |
| 139 | saAttr.nLength = sizeof(saAttr); |
| 140 | saAttr.bInheritHandle = TRUE; |
| 141 | saAttr.lpSecurityDescriptor = NULL; |
| 142 | if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){ |
| 143 | win32_fatal_error("cannot create pipe for stdout"); |
| 144 | } |
| 145 | SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE); |
| 146 | |
| @@ -148,16 +149,11 @@ | |
| 148 | win32_fatal_error("cannot create pipe for stdin"); |
| 149 | } |
| 150 | SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE); |
| 151 | |
| 152 | win32_create_child_process(fossil_utf8_to_unicode(zCmd), |
| 153 | hStdinRd,hStdoutWr,hStdoutWr,&childPid); |
| 154 | /* ^^^^^^^^^ ^^^^^^^^^ |
| 155 | ** Send both stdout and stderr to to *ppOut. |
| 156 | ** See check-in 857495ec92a521bb (2024-02-06) and earlier for |
| 157 | ** an example of how to leave stderr going to console */ |
| 158 | |
| 159 | *pChildPid = childPid; |
| 160 | *pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0); |
| 161 | fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0); |
| 162 | *ppOut = _fdopen(fd, "w"); |
| 163 | CloseHandle(hStdinRd); |
| @@ -198,13 +194,10 @@ | |
| 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 |
| --- src/popen.c | |
| +++ src/popen.c | |
| @@ -129,18 +129,19 @@ | |
| 129 | FILE **ppOut, /* Write to child using this file descriptor */ |
| 130 | int *pChildPid, /* PID of the child process */ |
| 131 | int bDirect /* 0: run zCmd as a shell cmd. 1: run directly */ |
| 132 | ){ |
| 133 | #ifdef _WIN32 |
| 134 | HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr; |
| 135 | SECURITY_ATTRIBUTES saAttr; |
| 136 | DWORD childPid = 0; |
| 137 | int fd; |
| 138 | |
| 139 | saAttr.nLength = sizeof(saAttr); |
| 140 | saAttr.bInheritHandle = TRUE; |
| 141 | saAttr.lpSecurityDescriptor = NULL; |
| 142 | hStderr = GetStdHandle(STD_ERROR_HANDLE); |
| 143 | if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){ |
| 144 | win32_fatal_error("cannot create pipe for stdout"); |
| 145 | } |
| 146 | SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE); |
| 147 | |
| @@ -148,16 +149,11 @@ | |
| 149 | win32_fatal_error("cannot create pipe for stdin"); |
| 150 | } |
| 151 | SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE); |
| 152 | |
| 153 | win32_create_child_process(fossil_utf8_to_unicode(zCmd), |
| 154 | hStdinRd, hStdoutWr, hStderr,&childPid); |
| 155 | *pChildPid = childPid; |
| 156 | *pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0); |
| 157 | fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0); |
| 158 | *ppOut = _fdopen(fd, "w"); |
| 159 | CloseHandle(hStdinRd); |
| @@ -198,13 +194,10 @@ | |
| 194 | close(1); |
| 195 | fd = dup(pin[1]); |
| 196 | if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1"); |
| 197 | close(pin[0]); |
| 198 | close(pin[1]); |
| 199 | if( bDirect ){ |
| 200 | execl(zCmd, zCmd, (char*)0); |
| 201 | }else{ |
| 202 | execl("/bin/sh", "/bin/sh", "-c", zCmd, (char*)0); |
| 203 | } |
| 204 |