gpt4 book ai didi

linux - strace 报告错误的文件描述符

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:44:02 26 4
gpt4 key购买 nike

尝试调试不返回 bash 提示符的程序,我使用了 strace并给它 PID。该程序是一个二进制文件,我没有源代码。根据strace , 有一个 -1 EBADF (Bad file descriptor) .但是,我不知道哪个文件有问题。

正如您在下方看到的 strace退出,所以运行 lsof -p <PID>没有结果。

read(5, "80\0\0\0\00078", 8)            = 8
read(5, "prf-exit\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 80) = 80
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2af316b0f000
write(1, "\n", 1) = 1
read(5, "\0\0\0\0", 4) = 4
write(5, "\0\0\0\0", 4) = 4
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 9
setsockopt(9, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(9, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(9, SOL_SOCKET, SO_SNDBUF, [65536], 4) = 0
setsockopt(9, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0
fcntl(9, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(9, F_SETFL, O_RDWR) = 0
connect(9, {sa_family=AF_INET, sin_port=htons(45323), sin_addr=inet_addr("10.10.10.251")}, 16) = 0
write(9, "12345\0", 6) = 6
write(9, "15 NORMAL_EXITING\0", 19) = 19
read(9, "\0", 1) = 1
close(9) = 0
futex(0x2af31686d9d0, FUTEX_WAIT, 29590, NULL) = 0
futex(0x2af31666c9d0, FUTEX_WAIT, 29589, NULL) = 0
close(6) = 0
close(7) = 0
read(5, "\0\0\0\0", 4) = 4
write(5, "\0\0\0\0", 4) = 4
read(5, "\0\0\0\0", 4) = 4
write(5, "\0\0\0\0", 4) = 4
close(5) = 0
close(5) = -1 EBADF (Bad file descriptor)
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
connect(5, {sa_family=AF_INET, sin_port=htons(49986), sin_addr=inet_addr("172.20.54.10")}, 16) = 0
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
write(5, "\35\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 64) = 64
close(5) = 0
close(4) = 0
exit_group(0) = ?
Process 29588 detached
[root@compute-0-3 ~]# lsof -p 29588
[root@compute-0-3 ~]#

如何搜索丢失/错误的文件?

最佳答案

您要关闭同一个文件描述符两次:

close(5)                                = 0
close(5) = -1 EBADF (Bad file descriptor)

关于linux - strace 报告错误的文件描述符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com