• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: I can capture stderr but can't capture stdout... unless debugging?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: I can capture stderr but can't capture stdout... unless debugging? (From: "John C. Daub" <email@hidden>)

  • Prev by Date: Re: NSImage doesn't accept background color?
  • Next by Date: Re: Multiple Inheritence (Was: Is _objc_flush_caches_(Class) necessary to swizzle methods?)
  • Previous by thread: Re: I can capture stderr but can't capture stdout... unless debugging?
  • Next by thread: [Newbie] Multiple NSTableViews
  • Index(es):
    • Date
    • Thread