summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-21 19:27:54 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-21 19:27:54 +0200
commitaa09d40fdcaf9abfe750929c5fe3b19ac1cef0cb (patch)
tree9b3fb66246e6993ada10922ef249cc0ee43d215e /lib
parent60a0355316954c96febd7bcd46862a4145a800cd (diff)
downloadabrt-aa09d40fdcaf9abfe750929c5fe3b19ac1cef0cb.tar.gz
abrt-aa09d40fdcaf9abfe750929c5fe3b19ac1cef0cb.tar.xz
abrt-aa09d40fdcaf9abfe750929c5fe3b19ac1cef0cb.zip
move most of CCrashWatcher's init/deinit into daemon's main()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils/xfuncs.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp
index c8aee376..cc147204 100644
--- a/lib/Utils/xfuncs.cpp
+++ b/lib/Utils/xfuncs.cpp
@@ -252,3 +252,41 @@ std::string get_home_dir(int uid)
struct passwd* pw = getpwuid(uid);
return pw ? pw->pw_dir : "";
}
+
+// Die if we can't open a file and return a fd
+int xopen3(const char *pathname, int flags, int mode)
+{
+ int ret;
+
+ ret = open(pathname, flags, mode);
+ if (ret < 0) {
+ perror_msg_and_die("can't open '%s'", pathname);
+ }
+ return ret;
+}
+
+// Die if we can't open an existing file and return a fd
+int xopen(const char *pathname, int flags)
+{
+ return xopen3(pathname, flags, 0666);
+}
+
+#if 0 //UNUSED
+// Warn if we can't open a file and return a fd.
+int open3_or_warn(const char *pathname, int flags, int mode)
+{
+ int ret;
+
+ ret = open(pathname, flags, mode);
+ if (ret < 0) {
+ perror_msg("can't open '%s'", pathname);
+ }
+ return ret;
+}
+
+// Warn if we can't open a file and return a fd.
+int open_or_warn(const char *pathname, int flags)
+{
+ return open3_or_warn(pathname, flags, 0666);
+}
+#endif