Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:45:46+00:00 2026-05-29T04:45:46+00:00

I am accessing a C function in Ruby through FFI. The function is called

  • 0

I am accessing a C function in Ruby through FFI. The function is called AllocTilts::summary.

I want the method to not print anything to STDOUT. However my temporary redirect of STDOUT is not working. Is there something else I can do?

puts 'test outside before' #prints successfully
File.open("/var/alloc_tilts/summary_dump", "w") do |out|
  stdout, $stdout = $stdout, out
  puts 'test inside' #doesn't print to STDOUT as expected
  AllocTilts.summary(2012, 2011) #prints undesired stuff to STDOUT
  $stdout = stdout
end
puts 'test outside after' #prints successfully
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:45:47+00:00Added an answer on May 29, 2026 at 4:45 am

    How do AllocTilts.summary write to stdout? If it uses printf and you do not have access to its source code there is nothing you can do (short of calling libc dup).

    The way ruby writes to $stdout rather than the real stdout, is

    # from io.c
    
    rb_funcall2(rb_stdout, rb_intern("puts"), argc, argv);
    

    You should use similar code to generate output inside AllocTilts.summary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Ruby and need help in accessing a function which is
When accessing the winapi method CloseHandle() via .net P/Invoke, should the argument be IntPtr
Hi I got this problem when accessing database: AttributeError at /renderForm/0 'function' object has
I'm accessing an array by reference inside a foreach loop, but the unset() function
I use psycopg2 for accessing my postgres database in python. My function should create
I am having trouble accessing a Javascript function from my code behind file. I
Related: Ambiguous overload accessing argument-less template functions with variadic parameters Simple variadic template function
I am having problems accessing sub-children of my displayObject. Here is my code:private function
$.ajax({ type: GET, url: something.html, dataType: xml, success:function(data){} , }); The content while accessing
I'm converting some javascript to coffeescript, and I'm having trouble accessing a function I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.