mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
743 B
35 lines
743 B
15 years ago
|
process.mixin(require("../common"));
|
||
16 years ago
|
|
||
15 years ago
|
var cat = process.createChildProcess("cat");
|
||
16 years ago
|
|
||
|
var response = "";
|
||
|
var exit_status = -1;
|
||
|
|
||
16 years ago
|
cat.addListener("output", function (chunk) {
|
||
16 years ago
|
puts("stdout: " + JSON.stringify(chunk));
|
||
16 years ago
|
if (chunk) {
|
||
|
response += chunk;
|
||
16 years ago
|
if (response === "hello world") {
|
||
|
puts("closing cat");
|
||
|
cat.close();
|
||
|
}
|
||
16 years ago
|
}
|
||
16 years ago
|
});
|
||
16 years ago
|
cat.addListener("error", function (chunk) {
|
||
16 years ago
|
puts("stderr: " + JSON.stringify(chunk));
|
||
15 years ago
|
assert.equal(null, chunk);
|
||
16 years ago
|
});
|
||
16 years ago
|
cat.addListener("exit", function (status) {
|
||
|
puts("exit event");
|
||
|
exit_status = status;
|
||
|
});
|
||
16 years ago
|
|
||
16 years ago
|
cat.write("hello");
|
||
|
cat.write(" ");
|
||
|
cat.write("world");
|
||
16 years ago
|
|
||
16 years ago
|
process.addListener("exit", function () {
|
||
15 years ago
|
assert.equal(0, exit_status);
|
||
|
assert.equal("hello world", response);
|
||
16 years ago
|
});
|