I just want to learn how I can dynamically to redirect linux process input/output/err(0/1/2) and I found that answer in in stack overflow How to redirect output of an already running process
As you can see the guide ask me to attach to the process trough gdb and invoke close() on the file descriptor and the create new one. Unfortunately cat (the test app) is not build with debug info and gdb complains that there is no such symbol as close. The same is true for the rest of the system commands that I tried.
What I need to do to have access to those symbols in gdb Also if you are able to provide alternative way to redirect the output of already running process without installing exotic tools or using gdb will be nice. Thanks
edit: gdb session
gdb -p 6836 /bin/cat
GNU gdb (GDB) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute
it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /bin/cat...
(No debugging symbols found in /bin/cat)
Attaching to program: /usr/bin/cat, process 6836
ptrace: No such process.
(gdb) p close(1)
No symbol table is loaded. Use the "file" command.
(gdb) file /bin/cat
Reading symbols from /bin/cat...
(No debugging symbols found in /bin/cat)
(gdb) p close(1)
No symbol table is loaded. Use the "file" command.
(gdb)