5 // Definition of non-inline non-template functions
7 #include "DaemonTools.hh"
8 //#include "DaemonTools.ih"
11 #include <sys/types.h>
17 #include "Exception.hh"
19 //#include "DaemonTools.mpp"
21 ///////////////////////////////cc.p////////////////////////////////////////
23 prefix_ void satcom::lib::daemonize()
27 throw satcom::lib::SystemException("fork",errno);
31 throw satcom::lib::SystemException("setsid",errno);
34 prefix_ void satcom::lib::redirect_stdio(std::string const & path)
36 int fd = ::open(path.c_str(),O_RDWR);
37 if (fd < 0) throw satcom::lib::SystemException("open",errno);
38 if (dup2(fd,0) < 0) throw satcom::lib::SystemException("dup2",errno);
39 if (dup2(fd,1) < 0) throw satcom::lib::SystemException("dup2",errno);
40 if (dup2(fd,2) < 0) throw satcom::lib::SystemException("dup2",errno);
41 if (::close(fd) < 0) throw satcom::lib::SystemException("close",errno);
44 ///////////////////////////////cc.e////////////////////////////////////////
46 //#include "DaemonTools.mpp"