0

Using truss -t'open' $(program_call) I get:

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

The thing is, I initialized the file descriptor to -1, so I KNOW that the open call must have succeeded because it changed the value of the variable. The file descriptor is literally initialized to -1, then somehow gets changed to 9 in the open command call (otherwise the program would end there) but yet the open call does NOT show up in the truss call, and the computer does not recognize it as being open.

Some code:

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);
tshepang
  • 12,111
  • 21
  • 91
  • 136
ICantNameMe
  • 93
  • 1
  • 1
  • 7
  • Can you show us the code? – thuovila May 06 '13 at 12:20
  • Most of it's here http://stackoverflow.com/questions/16395947/fifo-issue-with-concurrent-processes – ICantNameMe May 06 '13 at 12:21
  • 1
    Ah so its multithreaded. Did you notice this in the truss man-page Notes section:"The trace output for multiple processes or for a multithreaded process (one that contains more than one LWP) is not produced in strict time order. For example, a read() on a pipe can be reported before the corresponding write(). For any one LWP (a traditional process contains only one), the output is strictly time-ordered." – thuovila May 06 '13 at 12:23
  • Yes but regardless the open call is not getting executed. It's not the order. It's literally not being executed. – ICantNameMe May 06 '13 at 12:32
  • I left a suggestion for fix in your other question. – thuovila May 06 '13 at 12:33
  • Maybe parent change the fd? Add "-f" option to truss. – azat May 06 '13 at 12:45
  • `29023: open("response.txt", O_RDONLY|O_NONBLOCK) = 9` I found the open call with the -f flag, but it still doesn't seem to be working properly as `29021: open("response.txt", O_WRONLY|O_NONBLOCK) Err#6 ENXIO` force closes the program. I guess that means the call comes first for some reason... – ICantNameMe May 06 '13 at 12:55

1 Answers1

0

truss -f -t'open,close,read,write' run.sh was useful enough to find my errors, where run.sh was a bash file containing the proper execution of my program.

ICantNameMe
  • 93
  • 1
  • 1
  • 7