Redirecting input from gdb file
I cannot get gdb to redirect the file to the stdin of my program.
Outside, gdb ./prog.x < someinput.txt
does exactly what I want.
Inside gdb, when I run it (gdb) run < someinput.txt
, my program doesn't seem to "see" the input file, but instead stdin seems to read what I enter into the console.
(gdb) run < testinput.txt
Starting program: /Users/alexpatch/Documents/krc/misc/sandbox.x < testinput.txt
[New Thread 0x1603 of process 8308]
My cursor appears on a blank line below this where I can type text. Cd exits this, then prints the output of the program with what I just typed and the process exits normally.
/* trivial code example */
#include <stdio.h>
int main(void)
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
return 0;
}
I found several answers related to similar problems, but the solution that seemed to work for them was what I'm already doing, namely (gdb) run < someinput.txt
. In case this is helpful, I am working on a 64-bit MacBook Air running macOS Sierra.
source to share
No one has answered this question yet
See similar questions:
or similar: