Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Assigning to process.stdout has no effect #1878

Closed
mmalecki opened this issue Oct 13, 2011 · 7 comments
Closed

Assigning to process.stdout has no effect #1878

mmalecki opened this issue Oct 13, 2011 · 7 comments

Comments

@mmalecki
Copy link

I'm not sure if it's a bug or a desired behavior. I've tried bisecting, but many revisions failed to build on my system, so git left me in the middle of nowhere.

Doing:

process.stdout = require('fs').createWriteStream('/dev/null');

has no effect on node v0.5.x (console.logs and process.stdout.writes are still being printed), but works on node v0.4.x.

If that's a real issue, I'll provide a test case.

@aikar
Copy link

aikar commented Oct 13, 2011

I think its because your simply updating the property on process, your not ACTUALLY redirecting the FD 1 to /dev/null.

@mmalecki
Copy link
Author

@aikar I know the way around it (there are few ways, actually). It's more about the fact that it worked in node v0.4 (I've edited issue description to clarify it)

@bnoordhuis
Copy link
Member

Not really a bug. process.stdout is a getter now, you can override it (if you really want to) like this:

process.__defineGetter__('stdout', function() {
  return your_object;
});

@bnoordhuis
Copy link
Member

But maybe worth documenting on https://github.com/joyent/node/wiki/API-changes-between-v0.4-and-v0.6 !

@mmalecki
Copy link
Author

@bnoordhuis Thanks for a clarification and sorry for the unneeded buzz. Sure, I'll document it.

@mmalecki
Copy link
Author

Documented in e61f5c3, diff.

@bnoordhuis
Copy link
Member

Cool, thanks.

mmalecki added a commit to mmalecki/vows that referenced this issue Oct 13, 2011
In node v0.5.x `process.stdout` is a getter, so assigning to it makes
no difference (see nodejs/node-v0.x-archive#1878 - thanks @bnoordhuis).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants