Changeset: f7419ccd6b7c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f7419ccd6b7c
Modified Files:
clients/mapiclient/mclient.c
Branch: Nov2019
Log Message:
Move setting of SIGPIPE to main().
diffs (79 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -124,6 +124,8 @@ static timertype t0, t1; /* used for tim
#ifdef HAVE_POPEN
static char *pager = 0; /* use external pager */
+#endif
+#ifdef HAVE_SIGACTION
#include <signal.h> /* to block SIGPIPE */
#endif
static int rowsperpage = 0; /* for SQL pagination */
@@ -1808,36 +1810,27 @@ start_pager(stream **saveFD)
if (pager) {
FILE *p;
- struct sigaction act;
- /* ignore SIGPIPE so that we get an error instead of signal */
- act.sa_handler = SIG_IGN;
- (void) sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- if(sigaction(SIGPIPE, &act, NULL) == -1) {
+ p = popen(pager, "w");
+ if (p == NULL)
fprintf(stderr, "Starting '%s' failed\n", pager);
- } else {
- p = popen(pager, "w");
- if (p == NULL)
+ else {
+ *saveFD = toConsole;
+ /* put | in name to indicate that file should be closed
with pclose */
+ if ((toConsole = file_wastream(p, "|pager")) == NULL) {
+ toConsole = *saveFD;
+ *saveFD = NULL;
fprintf(stderr, "Starting '%s' failed\n",
pager);
- else {
- *saveFD = toConsole;
- /* put | in name to indicate that file should
be closed with pclose */
- if ((toConsole = file_wastream(p, "|pager")) ==
NULL) {
+ }
+#ifdef HAVE_ICONV
+ if (encoding != NULL) {
+ if ((toConsole = iconv_wstream(toConsole,
encoding, "pager")) == NULL) {
toConsole = *saveFD;
*saveFD = NULL;
fprintf(stderr, "Starting '%s'
failed\n", pager);
}
-#ifdef HAVE_ICONV
- if (encoding != NULL) {
- if ((toConsole =
iconv_wstream(toConsole, encoding, "pager")) == NULL) {
- toConsole = *saveFD;
- *saveFD = NULL;
- fprintf(stderr, "Starting '%s'
failed\n", pager);
- }
- }
+ }
#endif
- }
}
}
}
@@ -3322,6 +3315,16 @@ main(int argc, char **argv)
exit(2);
}
#endif
+#ifdef HAVE_SIGACTION
+ struct sigaction act;
+ /* ignore SIGPIPE so that we get an error instead of signal */
+ act.sa_handler = SIG_IGN;
+ (void) sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ if (sigaction(SIGPIPE, &act, NULL) == -1)
+ perror("sigaction");
+#endif
+
toConsole = stdout_stream = file_wastream(stdout, "stdout");
stderr_stream = file_wastream(stderr, "stderr");
if(!stdout_stream || !stderr_stream) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list