diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-11-16 01:00:05 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2012-11-16 01:00:05 +0000 |
commit | a469f8a57669e1948d5cc29005d8c097312de63a (patch) | |
tree | 4af697f80e08ff9f10989840ea8a2669b73b8e08 /backend/usb-darwin.c | |
parent | 76aa1ac14cceecf4968355e1ea6af822bce9cfc3 (diff) | |
download | cups-a469f8a57669e1948d5cc29005d8c097312de63a.tar.gz |
Merge changes from CUPS 1.7svn-r10704.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@4027 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'backend/usb-darwin.c')
-rw-r--r-- | backend/usb-darwin.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c index 5f303bec5..98cf9804a 100644 --- a/backend/usb-darwin.c +++ b/backend/usb-darwin.c @@ -96,6 +96,7 @@ #include <CoreFoundation/CoreFoundation.h> #include <IOKit/usb/IOUSBLib.h> #include <IOKit/IOCFPlugIn.h> +#include <libproc.h> #include <spawn.h> #include <pthread.h> @@ -134,6 +135,26 @@ extern char **environ; #define kUSBGenericTOPrinterClassDriver CFSTR("/System/Library/Printers/Libraries/USBGenericPrintingClass.plugin") #define kUSBPrinterClassDeviceNotOpen -9664 /*kPMInvalidIOMContext*/ +#define CRSetCrashLogMessage(m) _crc_make_setter(message, m) +#define _crc_make_setter(attr, arg) (gCRAnnotations.attr = (uint64_t)(unsigned long)(arg)) +#define CRASH_REPORTER_CLIENT_HIDDEN __attribute__((visibility("hidden"))) +#define CRASHREPORTER_ANNOTATIONS_VERSION 4 +#define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info" + +struct crashreporter_annotations_t { + uint64_t version; // unsigned long + uint64_t message; // char * + uint64_t signature_string; // char * + uint64_t backtrace; // char * + uint64_t message2; // char * + uint64_t thread; // uint64_t + uint64_t dialog_mode; // unsigned int +}; + +CRASH_REPORTER_CLIENT_HIDDEN +struct crashreporter_annotations_t gCRAnnotations + __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) + = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 }; /* * Section 5.3 USB Printing Class spec @@ -179,7 +200,7 @@ typedef struct classdriver_s /**** g.classdriver context ****/ UInt16 vendorID; /* Vendor id */ UInt16 productID; /* Product id */ printer_interface_t interface; /* identify the device to IOKit */ - UInt8 outpipe; /* mandatory bulkOut pipe */ + UInt8 outpipe; /* mandatory bulkOut pipe */ UInt8 inpipe; /* optional bulkIn pipe */ /* general class requests */ @@ -293,6 +314,7 @@ static pid_t child_pid; /* Child PID */ static void run_legacy_backend(int argc, char *argv[], int fd); /* Starts child backend process running as a ppc executable */ #endif /* __i386__ || __x86_64__ */ static void sigterm_handler(int sig); /* SIGTERM handler */ +static void sigquit_handler(int sig, siginfo_t *si, void *unused); #ifdef PARSE_PS_ERRORS static const char *next_line (const char *buffer); @@ -344,11 +366,21 @@ print_device(const char *uri, /* I - Device URI */ struct timeval *timeout, /* Timeout pointer */ tv; /* Time value */ struct timespec cond_timeout; /* pthread condition timeout */ + struct sigaction action; /* Actions for POSIX signals */ (void)uri; /* + * Catch SIGQUIT to determine who is sending it... + */ + + memset(&action, 0, sizeof(action)); + action.sa_sigaction = sigquit_handler; + action.sa_flags = SA_SIGINFO; + sigaction(SIGQUIT, &action, NULL); + + /* * See if the side-channel descriptor is valid... */ @@ -472,9 +504,6 @@ print_device(const char *uri, /* I - Device URI */ if (!print_fd) { - struct sigaction action; /* POSIX signal action */ - - memset(&action, 0, sizeof(action)); sigemptyset(&action.sa_mask); @@ -2094,6 +2123,32 @@ sigterm_handler(int sig) /* I - Signal */ } +/* + * 'sigquit_handler()' - SIGQUIT handler. + */ + +static void sigquit_handler(int sig, siginfo_t *si, void *unused) +{ + char *path; + char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; + static char msgbuf[256] = ""; + + + (void)sig; + (void)unused; + + if (proc_pidpath(si->si_pid, pathbuf, sizeof(pathbuf)) > 0 && + (path = basename(pathbuf)) != NULL) + snprintf(msgbuf, sizeof(msgbuf), "SIGQUIT sent by %s(%d)", path, (int)si->si_pid); + else + snprintf(msgbuf, sizeof(msgbuf), "SIGQUIT sent by PID %d", (int)si->si_pid); + + CRSetCrashLogMessage(msgbuf); + + abort(); +} + + #ifdef PARSE_PS_ERRORS /* * 'next_line()' - Find the next line in a buffer. |