Re: I can capture stderr but can't capture stdout... unless debugging?
Re: I can capture stderr but can't capture stdout... unless debugging?
- Subject: Re: I can capture stderr but can't capture stdout... unless debugging?
- From: Shaun Wexler <email@hidden>
- Date: Sat, 25 Sep 2004 19:47:05 -0700
On Sep 25, 2004, at 1:19 PM, John C. Daub wrote:
The code isn't mine to share (hence why I didn't post it), so I'll
have to
go ask the author if it's ok. If I can, I'll post it and continue this
thread. Else, I'll just try to figure it out using file descriptors
instead
of NSPipe's and NSFileHandle's.
This is the original idea:
if (!stdErrPipe) {
stdErrPipe = [[NSPipe alloc] init];
}
fileHandleForWriting = [stdErrPipe fileHandleForWriting];
fileHandleForReading = [stdErrPipe fileHandleForReading];
if (fileHandleForReading && fileHandleForWriting && (STDERR_FILENO ==
dup2([fileHandleForWriting fileDescriptor], STDERR_FILENO))) {
// loop to capture and log stdErr...
NSData *data = [fileHandleForReading availableData];
// log and process the data...
// optionally:
if (echoStdErrToStdOut) {
// copy to buffer, etc, then echo...
fprintf(stdout, (const char *)&buf);
etc...
John wants to log to STDOUT by default, optionally echoing to stderr.
For some reason, it's not working for him. He has substituted stdOut
for stdErr and vice-versa in the above code snippets and elsewhere.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden