From 9c239c6bb285fdd1e42b4001d2fb6bf6be8ec98c Mon Sep 17 00:00:00 2001 From: nedko Date: Thu, 8 Dec 2022 10:43:31 +0000 Subject: [PATCH] Fixed dest folder memory allocation. Added service file --- freemind-mindgen.service | 16 ++++++++++++++++ watcher.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 freemind-mindgen.service diff --git a/freemind-mindgen.service b/freemind-mindgen.service new file mode 100644 index 0000000..67f2e43 --- /dev/null +++ b/freemind-mindgen.service @@ -0,0 +1,16 @@ +[Unit] +Description=Calendar Auto Generator +After=network.target multi-user.target + +[Service] +Restart=always +RestartSec=1 +User=root +WorkingDirectory=/root/freemind-mindgen/ +ExecStart=/root/freemind-mindgen/watcher /root/calendar/ /var/www/links/calendar/ +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=CalendarGen + +[Install] +WantedBy=multi-user.target diff --git a/watcher.c b/watcher.c index 0e93a83..9b7f2a4 100644 --- a/watcher.c +++ b/watcher.c @@ -29,7 +29,7 @@ int is_dir(const char* _filepath); * * Returns -1 on error; */ -int execute_mindgen(); +int execute_mindgen(const char* _dest_dir, const char* _filename, const char* _source_dir); /* * Executes the deletion command @@ -184,7 +184,7 @@ int execute_mindgen(const char* dest_dir, const char* filename, const char* sour int pid; int child_status; char source_fullname[strlen(source_dir) + strlen(filename) + 2]; - char dest_fullname[strlen(source_dir) + strlen(filename) + 7]; + char dest_fullname[strlen(dest_dir) + strlen(filename) + 7]; char* arglist[4]; pid = fork();