FROM : Michael Ash
DATE : Sun Jul 02 21:28:09 2006
On 7/2/06, Frode <<email_removed>> 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
DATE : Sun Jul 02 21:28:09 2006
On 7/2/06, Frode <<email_removed>> 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
| Related mails | Author | Date |
|---|---|---|
| Damien Sorresso | Jul 1, 03:09 | |
| Chris Suter | Jul 1, 04:12 | |
| Frode | Jul 2, 10:51 | |
| Michael Ash | Jul 2, 21:28 | |
| Aleksandr Skobelev | Jul 3, 12:06 |






Cocoa mail archive

