Fix #16283 - Continue as normal even if detachee is not found (#16500)

This commit is contained in:
Khairul Azhar Kasmiran 2020-04-10 05:07:03 +08:00 committed by GitHub
parent d3bbfa95c6
commit f31e6ca527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -1600,7 +1600,7 @@ static int cmd_open(void *data, const char *input) {
{
int fd = (int)r_num_math (core->num, input + 1);
if (!r_core_file_close_fd (core, fd)) {
eprintf ("Unable to find filedescriptor %d\n", fd);
eprintf ("Unable to find file descriptor %d\n", fd);
}
}
break;

View File

@ -276,6 +276,10 @@ static int __close(RIODesc *desc) {
RIOPtrace *riop = desc->data;
desc->data = NULL;
long ret = r_io_ptrace (desc->io, PTRACE_DETACH, pid, 0, 0);
if (errno == ESRCH) {
// process does not exist, may have been killed earlier -- continue as normal
ret = 0;
}
free (riop);
return ret;
}

View File

@ -26,7 +26,7 @@ dbg:///bin/ls
EOF
RUN
NAME= ood after open in debug mode
NAME=ood after open in debug mode
FILE=../bins/elf/analysis/x86-helloworld-gcc
ARGS=-d
CMDS=<<EOF
@ -52,3 +52,19 @@ EXPECT=<<EOF
Hello world!
EOF
RUN
NAME=ood & om
FILE=../bins/elf/analysis/x86-helloworld-gcc
ARGS=-d
CMDS=<<EOF
om
?e
ood > /dev/null
om
EOF
EXPECT=<<EOF
1 fd: 3 +0x00000000 0x00000000 - 0x7ffffffffffffffe rwx
1 fd: 4 +0x00000000 0x00000000 - 0x7ffffffffffffffe rwx
EOF
RUN