使用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,然后在打开命令调用中以某种方式更改为9(否则程序将在那里结束),但是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);发布于 2013-05-14 21:54:50
truss -f -t'open,close,read,write' run.sh非常有用,可以找到我的错误,其中run.sh是一个包含程序正确执行的bash文件。
https://stackoverflow.com/questions/16398377
复制相似问题