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: Re: NSLog() and stderr



On 7/2/06, Frode <email@hidden> wrote:
void MyFLogv(FILE *fp, NSString *format, va_list argList) {
        int old_fd = dup(fileno(stderr));
        int new_fd = dup2(fileno(fp), fileno(stderr));

        NSLogv(format, argList);

        (void)dup2(old_fd, fileno(stderr));
}

Please, please do not do this. It's horrible and not thread safe. Don't use NSLog at all, use NSString to build a string using the format and argList, then write it out using fwrite or similar.

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

This email sent to email@hidden
References: 
 >Re: NSLog() and stderr (From: Frode <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.