使用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);