summaryrefslogtreecommitdiff
path: root/src/preproc/html
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2022-06-27 10:34:32 -0500
committerG. Branden Robinson <g.branden.robinson@gmail.com>2022-06-27 15:12:18 -0500
commit11137209eded488c5ecb598e13bd9450f004dd49 (patch)
tree382c03d142207f5631980790031be2a024407ea1 /src/preproc/html
parent87774cd7400c6ac79cddc6611dcf403a2ea46cb4 (diff)
downloadgroff-git-11137209eded488c5ecb598e13bd9450f004dd49.tar.gz
[pre-grohtml]: Fix Savannah #60782.
* src/preproc/html/pre-html.cpp (char_buffer::run_output_filter): Return wait status of child process. (char_buffer::run_output_filter, main): Rename local variable `status` to `wstatus` to recognize distinction between exit status (a 7-bit quantity) and wait status (a wider type). (main): Issue fatal diagnostic if child process exited with nonzero status. Since the child's output to the standard error stream is lost, advise re-running with different output driver to see them. This unhappy shortcoming is filed as Savannah #62673. Explicitly return zero otherwise. Fixes <https://savannah.gnu.org/bugs/?60782>.
Diffstat (limited to 'src/preproc/html')
-rw-r--r--src/preproc/html/pre-html.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 50ca49539..f15747f3a 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -1344,7 +1344,7 @@ int char_buffer::run_output_filter(int filter, int argc, char **argv)
{
int pipedes[2];
PID_T child_pid;
- int status;
+ int wstatus;
print_args(argc, argv);
if (pipe(pipedes) < 0)
@@ -1412,7 +1412,7 @@ int char_buffer::run_output_filter(int filter, int argc, char **argv)
// Finally, we must wait for the child process to complete.
- if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
+ if (WAIT(&wstatus, child_pid, _WAIT_CHILD) != child_pid)
sys_fatal("wait");
}
@@ -1479,7 +1479,7 @@ int char_buffer::run_output_filter(int filter, int argc, char **argv)
// And finally, we must wait for the child process to complete.
- if (WAIT(&status, child_pid, _WAIT_CHILD) != child_pid)
+ if (WAIT(&wstatus, child_pid, _WAIT_CHILD) != child_pid)
sys_fatal("wait");
#else /* can't do asynchronous pipes! */
@@ -1489,7 +1489,7 @@ int char_buffer::run_output_filter(int filter, int argc, char **argv)
#endif /* MAY_FORK_CHILD_PROCESS or MAY_SPAWN_ASYNCHRONOUS_CHILD */
- return 0;
+ return wstatus;
}
/*
@@ -1855,12 +1855,17 @@ int main(int argc, char **argv)
do_file("-");
if (makeTempFiles())
return 1;
- ok = inputFile.do_image(argc, argv);
- if (ok == 0) {
+ int wstatus = inputFile.do_image(argc, argv);
+ if (wstatus == 0) {
generateImages(regionFileName);
- ok = inputFile.do_html(argc, argv);
+ wstatus = inputFile.do_html(argc, argv);
}
- return ok;
+ else
+ if (WEXITSTATUS(wstatus) != 0)
+ fatal("'%1' exited with status %2; re-run '%1' with a different"
+ " output driver to see diagnostic messages", argv[0],
+ WEXITSTATUS(wstatus));
+ return 0;
}
static int do_file(const char *filename)