Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)



I did something similar. I stopped sending my debug information to CUPS and instead sent it to a log file that I control. Things work much better now.

Thanks,
Dave

On Mar 27, 2006, at 5:45 AM, email@hidden wrote:


I didn't have much success doing CUPS logging from my signal handler or the main printing code that I left when the signal occurred, so I thought my signal handler wasn't called, until I added short *p = 0; *p = 0xDEAD; The crash from my signal handler convinced me I'd entered it. Then I thought I wasn't returning to main code (when the above lines were removed). I was wrong both times, but didn't realize because nothing appeared from either process in the CUPS log.

I ended up creating and writing to two different files in /tmp to
satisfy myself that the signal handler (which sets an 'abort' flag)
was called and that the main code was able to read the flag and
act accordingly.

Not elegant, but good enough for my needs (and perhaps yours also).

> I'm trying to debug the cleanup section of my filter when it get a
> SIGTERM (e.g. canceling the job from the printer proxy) and I've
> found that I get a SIGPIPE on the next fprintf to stderr and none of
> my debug output after that makes it to the cups log.
>
> I've implemented the following code for signal handling:
>
> struct sigaction action;
> memset(&action, 0, sizeof(action));
> sigemptyset(&action.sa_mask);
> action.sa_sigaction = signalHandler;
> action.sa_flags |= SA_SIGINFO | SA_RESTART;
> if (sigaction(SIGTERM, &action, NULL) < 0)
> perror("DEBUG: Failed to set SIGTERM handler");
>
> memset(&action, 0, sizeof(action));
> sigemptyset(&action.sa_mask);
> action.sa_sigaction = signalHandler;
> action.sa_flags |= SA_SIGINFO | SA_RESTART;
> if (sigaction(SIGPIPE, &action, NULL) < 0)
> perror("DEBUG: Failed to set SIGPIPE handler");
>
> And my signal handler looks like:
>
> static void signalHandler(int signalNo, struct __siginfo *info, void
> *foo)
> {
> if (signalNo == SIGTERM)
> gSigTerm = YES;
> else if (signalNo == SIGPIPE)
> gSigPipe = YES;
> }
>
> With that I no longer get the SIGPIPE alert in gdb, but I still don't
> get my debug data either.
>
> Is this normal for Tiger? I wasn't that way in Panther as far as I
> can remember. Or did I botch my signal handling somehow?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Printing mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/printing/dave% 40criticalpath.com


This email sent to email@hidden

---
Among the chief weapons of UNIX: Fear, surprise and ruthless efficiency.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Printing mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/printing/email@hidden

This email sent to email@hidden
References: 
 >(no subject) (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.