[prev in list] [next in list] [prev in thread] [next in thread] 

List:       berlin-cvs
Subject:    [Fresco-changes] Fresco/Prague/src/IPC Coprocess.cc,1.21,1.22 PipeAgent.cc,1.11,1.12 ipcbuf.cc,1.18,
From:       Tobias Hunger <tobias () fresco ! org>
Date:       2003-11-07 23:46:39
[Download RAW message or body]

Update of /cvs/fresco/Fresco/Prague/src/IPC
In directory purcel:/tmp/cvs-serv6616/Prague/src/IPC

Modified Files:
	Coprocess.cc PipeAgent.cc ipcbuf.cc 
Log Message:
Throw std::runtime_error instead of using perror function in Prague.
Closes bug281.


Index: Coprocess.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/IPC/Coprocess.cc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Coprocess.cc	6 Nov 2003 18:04:01 -0000	1.21
+++ Coprocess.cc	7 Nov 2003 23:46:36 -0000	1.22
@@ -19,12 +19,14 @@
  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
  * MA 02139, USA.
  */
-#include "Prague/config.hh"
-#include "Prague/IPC/Coprocess.hh"
-#include "Prague/Sys/Signal.hh"
-#include "Prague/Sys/Tracer.hh"
+#include <Prague/config.hh>
+#include <Prague/IPC/Coprocess.hh>
+#include <Prague/Sys/Signal.hh>
+#include <Prague/Sys/Tracer.hh>
 
 #include <fstream>
+#include <sstream>
+#include <cerrno>
 
 #include <cstdio>
 #include <cerrno>
@@ -159,7 +161,7 @@
     return flag;
 }
 
-void Coprocess::terminate()
+void Coprocess::terminate() throw(std::runtime_error)
 {
     Signal::type sig;
     for (long ms = 0; pid(); ms++)
@@ -172,8 +174,12 @@
         Thread::delay(1);
     }
     Thread::delay(10);
-    if (pid()) std::cerr << "Coprocess " << pid() << " wouldn't die ("
-                         << Signal::name(sig) << ')' << std::endl;
+    if (pid())
+    {
+        std::stringstream os("Coprocess ");
+        os << pid() << " wouldn't die (" << Signal::name(sig) << ')' << std::endl;
+        throw std::runtime_error(os.str());
+    }
 }
 
 void Coprocess::shutdown(int m)
@@ -186,7 +192,9 @@
     if (m & err) delete _errbuf, _errbuf = 0;
 }
 
-void Coprocess::kill(Signal::type signum)
+void Coprocess::kill(Signal::type signum) throw(std::runtime_error)
 {
-    if (_id > 0 && ::kill(_id, int(signum)) < 0) std::perror("Coprocess::kill");
+    if (_id > 0 && ::kill(_id, int(signum)) < 0)
+        throw std::runtime_error(std::string("Coprocess::kill failed: ") +
+                                 strerror(errno));
 }

Index: PipeAgent.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/IPC/PipeAgent.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- PipeAgent.cc	6 Nov 2003 18:04:01 -0000	1.11
+++ PipeAgent.cc	7 Nov 2003 23:46:36 -0000	1.12
@@ -61,7 +61,8 @@
             argv[2] = _path.c_str();
             argv[3] = 0;
             execvp ("/bin/sh", (char**) argv);
-            std::perror("/bin/sh");
+            // Should not get here: report what went wrong and exit.
+            std::perror("Could not start /bin/sh: ");
             _exit(EXIT_FAILURE);
             break;
           default:

Index: ipcbuf.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/IPC/ipcbuf.cc,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ipcbuf.cc	31 Oct 2003 22:33:12 -0000	1.18
+++ ipcbuf.cc	7 Nov 2003 23:46:36 -0000	1.19
@@ -191,6 +191,7 @@
 }
 
 std::streamsize ipcbuf::sys_write(const char *buf, std::streamsize len)
+    throw(std::runtime_error)
 {
     // if (!writeready ()) return 0;
     std::streamsize wlen = 0;
@@ -202,7 +203,9 @@
         while (wval == -1 && errno == EINTR);
         if (wval == -1)
         {
-            if (errno != EAGAIN) perror("ipcbuf::write");
+            if (errno != EAGAIN)
+                throw std::runtime_error(std::string("ipcbuf::write failed: ") +
+                                         strerror(errno));
             return EOF;
         }
         len -= wval;
@@ -212,11 +215,14 @@
 }
 
 std::streamsize ipcbuf::sys_read(char *buf, std::streamsize len)
+    throw(std::runtime_error)
 {
     std::streamsize rval = -1;
     do
         rval = ::read(fd(), buf, len);
     while (rval == -1 && errno == EINTR);
-    if (rval == -1 && errno != EAGAIN) perror("ipcbuf::read");
+    if (rval == -1 && errno != EAGAIN)
+        throw std::runtime_error(std::string("ipcbuf::read failed: ") +
+                                 strerror(errno));
     return rval;
 }


_______________________________________________
Fresco-changes mailing list
Fresco-changes@fresco.org
http://lists.fresco.org/cgi-bin/listinfo/fresco-changes
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic