0

使用truss -t'open' $(program_call)我得到:

open("command.txt", O_RDONLY|O_NONBLOCK)      = 5
response FIFO file descriptor = -1
// Open call was literally sandwiched between print commands, but its not here?
response FIFO file descriptor = 9
open("response.txt", O_WRONLY|O_NONBLOCK)     Err#6 ENXIO
response.txt: No such device or address

问题是,我将文件描述符初始化为 -1,所以我知道 open 调用必须成功,因为它改变了变量的值。文件描述符实际上初始化为 -1,然后在 open 命令调用中以某种方式更改为 9(否则程序将在那里结束),但 open 调用并未显示在truss调用中,并且计算机无法将其识别为开放。

一些代码:

if ((outfd = open(CMD_FIFO_NAME, O_WRONLY | O_NONBLOCK)) == -1) {
    fprintf(stderr, "Client: Failed to open %s FIFO.\n", CMD_FIFO_NAME);
    exit(1);
}
printf("RESP_FIFO FILE DESCRIPTOR: %d\n", infd);
/* Open the response FIFO for non-blocking reads. */
if ((infd = open(RESP_FIFO_NAME, O_RDONLY | O_NONBLOCK)) == -1) {
    fprintf(stderr, "Client: Failed to open %s FIFO.\n", RESP_FIFO_NAME);
    exit(1);
}
else printf("RESP_FIFO FILE DESCRIPTOR: %d\n", infd);
4

1 回答 1

0

truss -f -t'open,close,read,write' run.sh足以找到我的错误,其中run.sh包含正确执行我的程序的 bash 文件。

于 2013-05-14T13:54:50.450 回答