about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-27 14:55:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-27 14:55:06 -0700
commit4896fd81a50814843680bd03fcba46643f08c95e (patch)
treef7ecff3efc8dabe75c562253e2fcfd7bb3a7b730
parentb1624806eb5664cc9915e615a3428d9049b1533f (diff)
downloadmu-4896fd81a50814843680bd03fcba46643f08c95e.tar.gz
3427
-rw-r--r--091socket.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/091socket.cc b/091socket.cc
index a06f4b1b..4725d282 100644
--- a/091socket.cc
+++ b/091socket.cc
@@ -145,7 +145,7 @@ case _READ_FROM_SOCKET: {
   char contents[bytes];
   bzero(contents, bytes);
   int bytes_read = read(socket_fd, contents, bytes - 1 /* null-terminated */);
-  //?: cerr << "Read:\n" << string(contents) << "\n";
+//?   cerr << "Read:\n" << string(contents) << "\n";
   products.resize(2);
   products.at(0).push_back(new_mu_text(string(contents)));
   products.at(1).push_back(bytes_read);
@@ -171,7 +171,10 @@ case _WRITE_TO_SOCKET: {
   // Write one character to a session at a time.
   long long int y = static_cast<long long int>(ingredients.at(1).at(0));
   char c = static_cast<char>(y);
-  write(session->fd, &c, 1);
+  if (write(session->fd, &c, 1) != 1) {
+    raise << maybe(current_recipe_name()) << "failed to write to socket\n" << end();
+    exit(0);
+  }
   long long int result = reinterpret_cast<long long int>(session);
   products.resize(1);
   products.at(0).push_back(result);