SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* */
-
+#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/* Log the failure */
exit(EXIT_FAILURE);
}
-
+ std::string name, dirname;
+ name = getenv("USER");
+ dirname = "/home/" + name + "/.mnenc/";
+ if(mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IRWXO ) < 0) {
+ if(errno != EEXIST) {
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* Change the current working directory */
- if ((chdir("/home/micke/.fifo")) < 0) {
+ if ((chdir("/tmp/")) < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
close(STDERR_FILENO);
/* Daemon-specific initialization goes here */
-
- mkfifo("./fife", 0777);
+ mkfifo("./mnencdfifo", 0777);
+ signal(SIGTERM, term); // register a SIGTERM handler
+ //raise(SIGTERM); // will cause term() to run
+
/* The Big Loop */
while (1) {
std::string request = m_read();
m_send(reply);
sleep(1); /* wait 1 second*/
}
- unlink("fife");
exit(EXIT_SUCCESS);
}