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: File descriptors problem




On Nov 14, 2008, at 14:37 , Tommy Nordgren wrote:

Is it possible, to via some low level API, set up a file descriptor so that any data written to it,
will be echoed to 2 or more other file descriptors?
I want to redirect the output of NSLog, to my own logfile, while keeping all current destinations of log
messages.
The only way I've found so far is to call the following function:

That's about the easiest way I can think of (which doesn't eliminate the possibility of easier or more effective approaches).


The problem is that "write()" just takes one file descriptor, and that's the choke point for output. You could write an "intercept" function that takes control when write() is called, uses its args to write to other fd's (that have been set up earlier) and then passes control to the real "write()". That's a lot of work, though.

HTH

Justin

--
Justin C. Walker, Curmudgeon-At-Large, Director
Institute for the Enhancement of the Director's Income
--------
The path of least resistance:
it's not just for electricity any more.
--------



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

This email sent to email@hidden
References: 
 >File descriptors problem (From: Tommy Nordgren <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.