Fresco/Prague/src/Sys File.cc,1.7,1.8 Fork.cc,1.9,1.10 Signal.cc,1.12,1.13 Stopwatch.cc,1.9,1.10
Tobias Hunger <[email protected]> Fri, 07 Nov 2003 23:46:39 +0000
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Prague/src/Sys
In directory purcel:/tmp/cvs-serv6616/Prague/src/Sys
Modified Files:
File.cc Fork.cc Signal.cc Stopwatch.cc
Log Message:
Throw std::runtime_error instead of using perror function in Prague.
Closes bug281.
Index: File.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Sys/File.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- File.cc 31 Oct 2003 22:33:13 -0000 1.7
+++ File.cc 7 Nov 2003 23:46:37 -0000 1.8
@@ -102,4 +102,4 @@
}
}
-const char *File::last_error() const { return strerror(_error); }
\ No newline at end of file
+const char *File::last_error() const { return strerror(_error); }
Index: Fork.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Sys/Fork.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Fork.cc 3 Nov 2003 17:53:54 -0000 1.9
+++ Fork.cc 7 Nov 2003 23:46:37 -0000 1.10
@@ -186,8 +186,9 @@
bool Fork::child() const { return process->pid == 0; }
bool Fork::parent() const { return process->pid > 0; }
pid_t Fork::pid() const { return process->pid; }
-void Fork::suicide_on_signal (Signal::type signo)
+void Fork::suicide_on_signal (Signal::type signo) throw(std::runtime_error)
{
if (!Signal::set(signo, &Process::suicide))
- std::perror ("Fork: Cannot commit suicide with the specified signal");
+ throw std::runtime_error(std::string("Fork: Cannot commit suicide with the specified signal: ") +
+ strerror(errno));
}
Index: Signal.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Sys/Signal.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Signal.cc 3 Nov 2003 17:53:54 -0000 1.12
+++ Signal.cc 7 Nov 2003 23:46:37 -0000 1.13
@@ -22,6 +22,7 @@
#include "Prague/config.hh"
#include "Prague/Sys/Signal.hh"
#include <cstring>
+#include <string>
#include <algorithm>
#include <cstdio>
@@ -161,7 +162,7 @@
return s;
}
-bool Signal::ispending(type signo)
+bool Signal::ispending(type signo) throw(std::runtime_error)
{
sigset_t s = pending();
switch (sigismember(&s, type(signo)))
@@ -169,7 +170,8 @@
case 1:
return true;
case -1:
- perror("Signal::ispending: ");
+ throw std::runtime_error(std::string("Signal::ispending failed: ") +
+ strerror(errno));
case 0:
default:
return false;
Index: Stopwatch.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Prague/src/Sys/Stopwatch.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Stopwatch.cc 31 Oct 2003 22:33:13 -0000 1.9
+++ Stopwatch.cc 7 Nov 2003 23:46:37 -0000 1.10
@@ -24,6 +24,8 @@
#include <sys/times.h>
#include <unistd.h>
+#include <cerrno>
+#include <string>
using namespace Prague;
@@ -35,24 +37,28 @@
start();
}
-void Stopwatch::start()
+void Stopwatch::start() throw(std::runtime_error)
{
_state = running;
struct tms cpt;
_real.begin = times(&cpt);
_cpu.begin = cpt.tms_utime;
_sys.begin = cpt.tms_stime;
- if (_real.begin == -1) perror("Stopwatch::start");
+ if (_real.begin == -1)
+ throw std::runtime_error(std::string("Failed to start the Stopwatch: ") +
+ strerror(errno));
}
-void Stopwatch::stop()
+void Stopwatch::stop() throw(std::runtime_error)
{
_state = stopped;
struct tms cpt;
_real.end = times(&cpt);
_cpu.end = cpt.tms_utime;
_sys.end = cpt.tms_stime;
- if (_real.end == -1) perror("Stopwatch::stop");
+ if (_real.end == -1)
+ throw std::runtime_error(std::string("Failed to stop the Stopwatch: ") +
+ strerror(errno));
}
double Stopwatch::real_time()