in reply to Calling strace -f
in thread Diagnosing blocking io (or: finding the WHY of my Open2 woes).
read(0, "load(\'jslint.js\');\nfoo=0;\nEND\n", 1024) = 30 read(0, "", 1024) = 0 read(0, "", 1024) = 0 close(0) = 0 <-- !!! munmap(0xb7b8a000, 4096) = 0 brk(0x8092000) = 0x8092000 open("jslint.js", O_RDONLY) = 0
I think the problem is this close(0). Because of it, the file descriptor is being reused in the subsequent open("jslint.js" (as the lowest available file descriptor) when the js interpreter is reading in the jslint.js file, at the end of which it gets closed again... Anyhow, the net effect of this is that stdin (which is expected to be connected to the pipe) is no longer open when your line=readline() is trying to read from it. Thus the readline is failing, and the while (true) {...} keeps looping forever...
Note that when being run interactively, the jslint.js file is read in via a different file descriptor, and stdin (file descriptor 0) can still be read from afterwards.
I'd suspect the undesirable close(0) has to do with you closing the other end of the pipe ($JSWRITE) before the js interpreter starts executing the load('jslint.js'); command you sent it. So that's where I would start fiddling... (if I really wanted to know :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Calling strace -f
by Socrates (Acolyte) on Nov 19, 2008 at 22:17 UTC | |
by almut (Canon) on Nov 19, 2008 at 22:26 UTC | |
by ikegami (Patriarch) on Nov 20, 2008 at 01:58 UTC | |
by ikegami (Patriarch) on Nov 20, 2008 at 02:25 UTC |