Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Unified Diff: build_tools/pipeserver.js

Issue 1742043002: Make M-x shell work in emacs. (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: fix Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build_tools/naclprocess.js ('k') | docs/port_list.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build_tools/pipeserver.js
diff --git a/build_tools/pipeserver.js b/build_tools/pipeserver.js
index aa1479507cc387b83709321ef83e7c97cbb3f84b..0241d76c2b23379328482ce5a047d2bf5bb76fd8 100644
--- a/build_tools/pipeserver.js
+++ b/build_tools/pipeserver.js
@@ -24,6 +24,12 @@ function PipeServer() {
PipeServer.prototype.EPIPE = 32;
/**
+ * EAGAIN / EWOULDBLOCK.
+ * @type {number}
+ */
+PipeServer.prototype.EAGAIN = 11;
+
+/**
* Handle an anonymous pipe creation call.
*/
PipeServer.prototype.handleMessageAPipe = function(msg, reply, src) {
@@ -63,6 +69,7 @@ PipeServer.prototype.handleMessageAPipeWrite = function(
var part = data.slice(0, item.count);
item.reply({
data: part,
+ error: 0,
});
data = data.slice(part.byteLength);
}
@@ -103,11 +110,13 @@ PipeServer.prototype.handleMessageAPipeRead = function(
msg, reply, src) {
var id = msg.pipe_id;
var count = msg.count;
+ var nonblock = msg.nonblock;
if (count === 0 ||
!(id in this.anonymousPipes &&
src.pid in this.anonymousPipes[id].readers)) {
reply({
data: new ArrayBuffer(0),
+ error: 0,
});
return;
}
@@ -118,12 +127,14 @@ PipeServer.prototype.handleMessageAPipeRead = function(
var part = item.data.slice(0, count);
reply({
data: part,
+ error: 0,
});
item.data = item.data.slice(part.byteLength);
pipe.writesPending.unshift(item);
} else {
reply({
data: item.data,
+ error: 0,
});
if (!item.replied) {
item.reply({
@@ -133,14 +144,21 @@ PipeServer.prototype.handleMessageAPipeRead = function(
}
} else {
if (Object.keys(pipe.writers).length > 0) {
- pipe.readsPending.push({
- count: count,
- reply: reply,
- pid: src.pid,
- });
+ if (nonblock !== 0) {
+ reply({
+ error: this.EAGAIN,
+ });
+ } else {
+ pipe.readsPending.push({
+ count: count,
+ reply: reply,
+ pid: src.pid,
+ });
+ }
} else {
reply({
data: new ArrayBuffer(0),
+ error: 0,
});
}
}
@@ -165,6 +183,7 @@ PipeServer.prototype.closeAPipe = function(pid, pipeId, writer) {
var item = pipe.readsPending[i];
item.reply({
data: new ArrayBuffer(0),
+ error: 0,
});
}
pipe.readsPending = [];
@@ -194,9 +213,12 @@ PipeServer.prototype.handleMessageAPipeClose = function(
/**
* Add spawned pipe entries.
+ * @pid {Object} Numeric process for which to add pipes.
* @params {Object} Dictionary of environment variables passed to process.
+ * @returns {boolean} True if stdin is routed.
*/
PipeServer.prototype.addProcessPipes = function(pid, params) {
+ var routeStdin = false;
var fdCount = 0;
for (;;fdCount++) {
var entry = 'NACL_SPAWN_FD_SETUP_' + fdCount;
@@ -209,6 +231,9 @@ PipeServer.prototype.addProcessPipes = function(pid, params) {
var fd = parseInt(m[1]);
var id = parseInt(m[2]);
var isWriter = parseInt(m[3]);
+ if (fd === 0) {
+ routeStdin = true;
+ }
if (id in this.anonymousPipes) {
var pipe = this.anonymousPipes[id];
if (isWriter) {
@@ -219,6 +244,7 @@ PipeServer.prototype.addProcessPipes = function(pid, params) {
}
}
}
+ return routeStdin;
};
« no previous file with comments | « build_tools/naclprocess.js ('k') | docs/port_list.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698