summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2021-04-09 10:09:12 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2021-04-09 10:09:12 -0400
commit1ab278c3d04207b846c75b0c2fd58aba5b7d458c (patch)
treee1aaa45348ceb23aabc125641761edcc16a0c569 /backend
parenta3fb828390bef5b915abcafdb4e66ce428ffec40 (diff)
downloadcups-1ab278c3d04207b846c75b0c2fd58aba5b7d458c.tar.gz
Fix backend logging from signal handlers (OpenPrinting #167)
Diffstat (limited to 'backend')
-rw-r--r--backend/backend-private.h12
-rw-r--r--backend/ipp.c4
-rw-r--r--backend/snmp.c2
-rw-r--r--backend/testbackend.c5
-rw-r--r--backend/usb-darwin.c6
5 files changed, 20 insertions, 9 deletions
diff --git a/backend/backend-private.h b/backend/backend-private.h
index 85fb8aef8..d19b06b82 100644
--- a/backend/backend-private.h
+++ b/backend/backend-private.h
@@ -1,7 +1,8 @@
/*
* Backend support definitions for CUPS.
*
- * Copyright © 2007-2014 by Apple Inc.
+ * Copyright © 2021 by OpenPrinting
+ * Copyright © 2007-2021 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
@@ -53,6 +54,14 @@ extern "C" {
/*
+ * Log messages in backend signal handlers or other places where stdio cannot
+ * be used...
+ */
+
+# define backendMessage(msg) {const char *s = msg; write(2, s, strlen(s));}
+
+
+/*
* OID constants...
*/
@@ -320,7 +329,6 @@ extern int backendSNMPSupplies(int snmp_fd, http_addr_t *addr,
extern int backendWaitLoop(int snmp_fd, http_addr_t *addr,
int use_bc, _cups_sccb_t side_cb);
-
# ifdef __cplusplus
}
# endif /* __cplusplus */
diff --git a/backend/ipp.c b/backend/ipp.c
index 8b1976990..63353a66d 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -3418,7 +3418,7 @@ sigterm_handler(int sig) /* I - Signal */
{
(void)sig; /* remove compiler warnings... */
- write(2, "DEBUG: Got SIGTERM.\n", 20);
+ backendMessage("DEBUG: Got SIGTERM.\n");
#if defined(HAVE_GSSAPI) && defined(HAVE_XPC)
if (child_pid)
@@ -3434,7 +3434,7 @@ sigterm_handler(int sig) /* I - Signal */
* Flag that the job should be canceled...
*/
- write(2, "DEBUG: sigterm_handler: job_canceled = 1.\n", 25);
+ backendMessage("DEBUG: sigterm_handler: job_canceled = 1.\n");
job_canceled = 1;
return;
diff --git a/backend/snmp.c b/backend/snmp.c
index 9572822a8..084c6f511 100644
--- a/backend/snmp.c
+++ b/backend/snmp.c
@@ -424,7 +424,7 @@ alarm_handler(int sig) /* I - Signal number */
#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */
if (DebugLevel)
- write(2, "DEBUG: ALARM!\n", 14);
+ backendMessage("DEBUG: ALARM!\n");
}
diff --git a/backend/testbackend.c b/backend/testbackend.c
index 6dbd0abee..6412a022b 100644
--- a/backend/testbackend.c
+++ b/backend/testbackend.c
@@ -19,6 +19,7 @@
#include <fcntl.h>
#include <sys/wait.h>
#include <signal.h>
+#include "backend-private.h"
/*
@@ -395,7 +396,7 @@ main(int argc, /* I - Number of command-line args */
data = ps_data;
write(1, data, strlen(data));
- write(2, "DEBUG: START\n", 13);
+ backendMessage("DEBUG: START\n");
timeout = 60.0;
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
@@ -403,7 +404,7 @@ main(int argc, /* I - Number of command-line args */
write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
- write(2, "\nDEBUG: END\n", 12);
+ backendMessage("\nDEBUG: END\n");
}
exit(0);
diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c
index 3f03630f0..3a8feffb6 100644
--- a/backend/usb-darwin.c
+++ b/backend/usb-darwin.c
@@ -1,5 +1,7 @@
/*
- * Copyright 2005-2016 Apple Inc. All rights reserved.
+ * USB backend for macOS.
+ *
+ * Copyright © 2005-2021 Apple Inc. All rights reserved.
*
* IMPORTANT: This Apple software is supplied to you by Apple Computer,
* Inc. ("Apple") in consideration of your agreement to the following
@@ -2230,7 +2232,7 @@ sigterm_handler(int sig) /* I - Signal */
_exit(0);
else
{
- write(2, "DEBUG: Child crashed.\n", 22);
+ backendMessage("DEBUG: Child crashed.\n");
_exit(CUPS_BACKEND_STOP);
}
}