Skip to main content
typo stdout stdin
Source Link

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,fileno(stdinstdout)) $2 = 1 (gdb) call close($1) ... (gdb) detach ... 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY equals 1 and fileno(stdinstdout) equals 1 . use literal values or gdb may complain lack of symbols .


and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,fileno(stdin)) $2 = 1 (gdb) call close($1) ... (gdb) detach ... 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY equals 1 and fileno(stdin) equals 1 . use literal values or gdb may complain lack of symbols .


and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,fileno(stdout)) $2 = 1 (gdb) call close($1) ... (gdb) detach ... 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY equals 1 and fileno(stdout) equals 1 . use literal values or gdb may complain lack of symbols .


and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 
cast file stream to coresponding fd
Source Link

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,1fileno(stdin)) $2 = 01 (gdb) call close($1) $3 = 0... (gdb) detach ... 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY is referenced through fcntl.h ,equals 1 and has valuefileno(stdin) equals 1 . use literal values or gdb may complain lack of symbols . 


and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,1) $2 = 0 (gdb) call close($1) $3 = 0 (gdb) detach 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY is referenced through fcntl.h , and has value 1 . and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,fileno(stdin)) $2 = 1 (gdb) call close($1) ... (gdb) detach ... 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY equals 1 and fileno(stdin) equals 1 . use literal values or gdb may complain lack of symbols . 


and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 
typo
Source Link

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,1) $2 = 0 (gdb) call close($1) $3 = 0 (gdb) detach 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here according to headerO_WRONLY is referenced through fcntl.h O_WRONLY, and has value 1 . and if we want to find a a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,1) $2 = 0 (gdb) call close($1) $3 = 0 (gdb) detach 

here according to header fcntl.h O_WRONLY has value 1 . and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 

let me yank here the solution @jimmij pointed to , with minor modification .

(gdb) attach <pid> ... (gdb) call open("/dev/null",O_WRONLY) $1 = 3 (gdb) call dup2($1,1) $2 = 0 (gdb) call close($1) $3 = 0 (gdb) detach 

for those not familiar with gdb , "attach" "call" "detach" are gdb commands . get information with "help attach" inside a gdb prompt . and "open" "dup2" "close" are library functions . get information with "man 2 open" .

here O_WRONLY is referenced through fcntl.h , and has value 1 . and if we want to find a file descriptor already opened , we can .

$ cd /proc/<pid>/fd $ for i in * ; do if [[ `readlink $i` == "/dev/null" ]] fd=$i ; break fi done 
Source Link
Loading