Skip to content

Commit

Permalink
Good enough for working on #236
Browse files Browse the repository at this point in the history
* hack to use stderr for Ruby since I can't find a better way to
  tell ruby that stdout has changed.
  • Loading branch information
Cecil committed May 11, 2016
1 parent afd0a49 commit cc2a21a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bugs/bug236.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
if RUBY_PLATFORM =~ /darwin/
#$stderr.puts "Filenums #{STDOUT.fileno} #{STDERR.fileno}"
#$stdout = $stderr
#$stdout.reopen($stdout)
#$stdout = IO.new(1, 'w')
end
$stderr.puts "STDERR OK"
$stdout.puts "STDOUT OK"
Expand Down
10 changes: 7 additions & 3 deletions shoes/console/cocoa-term.m
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,15 @@ - (void)consoleInitWithFont: (NSFont *) font
// above results in one call to stdOutDataAvail

stdout = fdopen(pipewrfd, "w");
printf("Hello from FILE* stdout"); // not working
if (setlinebuf(stdout) != 0) {
fprintf(stderr, "failed setlinebuffer()\n");
}
fflush(stdout); // doesn't work
printf("Hello from FILE* stdout\n"); // Yay!!

[outWriteHandle writeData: pipeMsgData];


// now convince Ruby to use the new stdout
rb_eval_string("$stdout = $stderr");
} else {
dup2fail = errno;
}
Expand Down

1 comment on commit cc2a21a

@ccoupe
Copy link

@ccoupe ccoupe commented on cc2a21a May 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag #224

Please sign in to comment.