我正在尝试在以下简单脚本(称为te.js)上运行phantomjs并在其上使用ubuntu 12.04上的“strace”:
$ strace -o tmp.txt -e poll,select,connect,recv,sendto,recvfrom ./bin/phantomjs --disk-cache false te.js
以下是javascript脚本:
var page = require('webpage').create();
var system = require('system');
page.onConsoleMessage = function(msg) {
system.stderr.writeLine('console: ' + msg);
};
page.open('http://st.pimg.net/tucs/img/cpan_banner.png', function() {
console.log("got image\n");
});
这是strace写给tmp.txt
的内容poll([{fd=7, events=POLLIN}], 1, 10) = 1 ([{fd=7, revents=POLLIN}])
select(4, [3], [], [], {0, 0}) = 1 (in [3], left {0, 0})
select(4, [3], [], [], {0, 0}) = 1 (in [3], left {0, 0})
select(4, [3], [], [], NULL) = 1 (in [3])
select(4, [3], [], [], {0, 0}) = 1 (in [3], left {0, 0})
select(4, [3], [], [], NULL) = ? ERESTARTNOHAND (To be restarted)
--- SIGINT (Interrupt) @ 0 (0) ---
+++ killed by SIGINT +++
我原本打算看到“连接”的电话,但我没有。想知道为什么。
顺便说一句,我使用了wireshark,它表明phantomjs确实尝试建立与HTTP服务器的连接。