From 067b80f195ed88e3362265c5bae6ccc2b7f54aa7 Mon Sep 17 00:00:00 2001 From: "Alexey N. Vinogradov" Date: Fri, 29 Mar 2019 10:16:50 +0700 Subject: [PATCH] Fix sigpipe handler CUPS manual recommends to ignore SIGPIPE signal in filters (since when they're in chain, children may stop and such signal will disturb others) We are not intended to be used in chain, however let's follow the recommendation. --- rastertozj.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rastertozj.c b/rastertozj.c index d887b23..7ee0c71 100644 --- a/rastertozj.c +++ b/rastertozj.c @@ -208,7 +208,7 @@ typedef void (*__sighandler_t)(int); __sighandler_t old_signal; void finishPage() { - signal(15, old_signal); + signal(SIGTERM, old_signal); } // sent on job canceling @@ -220,7 +220,7 @@ void cancelJob() { } // invoked before starting to print a page -void startPage() { old_signal = signal(15, cancelJob); } +void startPage() { old_signal = signal(SIGTERM, cancelJob); } void DebugPrintHeader (cups_page_header2_t* pHeader) { @@ -387,6 +387,9 @@ static inline void send_raster(const unsigned char *pBuf, int width8, ////////////////////////////////////////////// ////////////////////////////////////////////// int main(int argc, char *argv[]) { + + signal(SIGPIPE, SIG_IGN); + if (argc < 6 || argc > 7) { fputs("ERROR: rastertozj job-id user title copies options [file]\n", stderr);