Fossil SCM

Stderr of ssh subcommand goes is read by the main process now, instead of going to the console. Improved error messages following failure on ssh: sync.

drh 2024-02-06 13:57 trunk
Commit fb156a12bfa2aefbca413f9b7affa2b299d5eefb28ab0d16e92e9c97e3e8a00a
2 files changed +6 -1 +7 -3
+6 -1
--- src/http.c
+++ src/http.c
@@ -525,11 +525,16 @@
525525
}
526526
return rc;
527527
}else{
528528
/* The problem could not be corrected by retrying. Report the
529529
** the error. */
530
- fossil_warning("server did not reply");
530
+ if( g.url.isSsh && !g.fSshTrace ){
531
+ fossil_warning("server did not reply: "
532
+ " rerun with --sshtrace for diagnostics");
533
+ }else{
534
+ fossil_warning("server did not reply");
535
+ }
531536
goto write_err;
532537
}
533538
}
534539
if( rc!=200 ){
535540
fossil_warning("\"location:\" missing from %d redirect reply", rc);
536541
--- src/http.c
+++ src/http.c
@@ -525,11 +525,16 @@
525 }
526 return rc;
527 }else{
528 /* The problem could not be corrected by retrying. Report the
529 ** the error. */
530 fossil_warning("server did not reply");
 
 
 
 
 
531 goto write_err;
532 }
533 }
534 if( rc!=200 ){
535 fossil_warning("\"location:\" missing from %d redirect reply", rc);
536
--- src/http.c
+++ src/http.c
@@ -525,11 +525,16 @@
525 }
526 return rc;
527 }else{
528 /* The problem could not be corrected by retrying. Report the
529 ** the error. */
530 if( g.url.isSsh && !g.fSshTrace ){
531 fossil_warning("server did not reply: "
532 " rerun with --sshtrace for diagnostics");
533 }else{
534 fossil_warning("server did not reply");
535 }
536 goto write_err;
537 }
538 }
539 if( rc!=200 ){
540 fossil_warning("\"location:\" missing from %d redirect reply", rc);
541
+7 -3
--- src/popen.c
+++ src/popen.c
@@ -129,19 +129,18 @@
129129
FILE **ppOut, /* Write to child using this file descriptor */
130130
int *pChildPid, /* PID of the child process */
131131
int bDirect /* 0: run zCmd as a shell cmd. 1: run directly */
132132
){
133133
#ifdef _WIN32
134
- HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr;
134
+ HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr;
135135
SECURITY_ATTRIBUTES saAttr;
136136
DWORD childPid = 0;
137137
int fd;
138138
139139
saAttr.nLength = sizeof(saAttr);
140140
saAttr.bInheritHandle = TRUE;
141141
saAttr.lpSecurityDescriptor = NULL;
142
- hStderr = GetStdHandle(STD_ERROR_HANDLE);
143142
if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){
144143
win32_fatal_error("cannot create pipe for stdout");
145144
}
146145
SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE);
147146
@@ -149,11 +148,16 @@
149148
win32_fatal_error("cannot create pipe for stdin");
150149
}
151150
SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE);
152151
153152
win32_create_child_process(fossil_utf8_to_unicode(zCmd),
154
- hStdinRd, hStdoutWr, hStderr,&childPid);
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
+
155159
*pChildPid = childPid;
156160
*pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0);
157161
fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0);
158162
*ppOut = _fdopen(fd, "w");
159163
CloseHandle(hStdinRd);
160164
--- src/popen.c
+++ src/popen.c
@@ -129,19 +129,18 @@
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
@@ -149,11 +148,16 @@
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);
160
--- src/popen.c
+++ src/popen.c
@@ -129,19 +129,18 @@
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
@@ -149,11 +148,16 @@
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);
164

Keyboard Shortcuts

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