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

  • Home
  • SEARCH
  • 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 8677153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:22:58+00:00 2026-06-12T20:22:58+00:00

I am trying to debug a program that needs to read EOF as an

  • 0

I am trying to debug a program that needs to read EOF as an input.

However, when I hit Control-D to send EOF when the program is running in GDB, GDB traps the EOF and does not pass it to the application.

How can I cause gdb to send the EOF to the application?

  • 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-06-12T20:22:59+00:00Added an answer on June 12, 2026 at 8:22 pm

    However, when I hit Control-D to send EOF when the program is running in GDB, GDB traps the EOF and does not pass it to the application.

    GDB does not do any such thing.

    In a normal (all-stop) mode, either the application, or the GDB has control of the terminal, but not both.

    If the application is reading the terminal input, then Control-D will cause it to read EOF, and GDB will not interfere with that.

    If you are looking at the (gdb) prompt, then the application is not reading the input — it is stopped — and sending Control-D will indeed send EOF to GDB. Don’t do that.

    Example:

    gdb -q /bin/cat
    Reading symbols from /bin/cat...done.
    
    (gdb) run
    Starting program: /bin/cat 
    foof     # my input
    foof     # cat output
             # Control-D
    [Inferior 1 (process 12782) exited normally]  # cat received EOF and exited
    (gdb) run
    Starting program: /bin/cat 
    foof     # my input
    foof     # cat output
    ^C
    Program received signal SIGINT, Interrupt.
    0x00007ffff7b31ee0 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
    82  ../sysdeps/unix/syscall-template.S: No such file or directory.
    (gdb) quit   # I typed Control-D, GDB translated that into quit
    A debugging session is active.
    
        Inferior 1 [process 12787] will be killed.
    
    Quit anyway? (y or n) y
    

    Update:

    I am hitting Control-D when the application is reading (not at gdb prompt), and the application does not acknowledge that it received Control-D. When the application tries to read, it reads 0 bytes.

    That’s exactly what is supposed to have happened (read returning 0 means that you’ve reached end of file). If you are expecting the application to read magical EOF symbol, your expectation is wrong — there is no such symbol.

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

Sidebar

Related Questions

I am trying to debug a program that unexpectedly shuts down. When I say
While I trying to debug a 'C' program with gdb, I always get the
i'm trying to debug a program, that i don't have the source code for:
I'm trying to read lines from a SIC/XE program using a C program that
I have this output when trying to debug Program received signal SIGSEGV, Segmentation fault
When trying to debug a program on Windows I can't seem to find where
I'm trying to debug an old VB6 program at my job. It's full of
I'm trying to debug an objective C program. It used to run, and I'm
I am trying to extract debug information from a compiled C program with C#,
I'm trying to debug a web page that makes heavy use of events, and

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.