From 9148dac885c0325636c2d33715ba248371706d0d Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Fri, 09 Jul 2004 16:48:52 +0000 Subject: dudki: initial import into svn repository --- (limited to 'src/util.cc') diff --git a/src/util.cc b/src/util.cc new file mode 100644 index 0000000..afb2641 --- a/dev/null +++ b/src/util.cc @@ -0,0 +1,21 @@ +#include +#include +#include +using namespace std; +#include "util.h" + +void pid_file::set(const string& f,bool u) { + ofstream of(f.c_str(),ios::trunc); + if(!of) + throw runtime_error(string(__PRETTY_FUNCTION__)+": failed to open file for writing pid"); + of << getpid() << endl; + of.close(); + file_name = f; + unlink_pid = u; +} +void pid_file::unlink() { + if(!unlink_pid) + return; + ::unlink(file_name.c_str()); +} + -- cgit v0.9.0.2