From a74a4b77a578969b055937680d6bf3829e83afd4 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 29 Sep 2022 10:03:27 +0800 Subject: [PATCH] update: crontab signal with specific pid --- src/applet/crontab.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/applet/crontab.c b/src/applet/crontab.c index ddd18d7..2dbf799 100644 --- a/src/applet/crontab.c +++ b/src/applet/crontab.c @@ -1,4 +1,5 @@ #include +#include #include "logger.h" #include "sundry.h" #include "system.h" @@ -27,10 +28,13 @@ void crontab_dump(crontab *info) { // show crontab options in debug log process* crontab_load(crontab *info) { // load crontab options crontab_dump(info); - // TODO: use getpid() - char *cron_cmd = string_join(info->cron, " kill -14 $(ps -o pid,comm | grep cleardns | awk '{print $1}')"); - save_file("/var/spool/cron/crontabs/root", cron_cmd); // SIGALRM -> 14 + char *my_pid = uint32_to_string(getpid()); + char *cron_cmd = string_join("\tkill -14 ", my_pid); // SIGALRM -> 14 + char *cron_exp = string_join(info->cron, cron_cmd); + save_file("/var/spool/cron/crontabs/root", cron_exp); + free(cron_exp); free(cron_cmd); + free(my_pid); process *proc = process_init("Crontab", "crond"); process_add_arg(proc, "-f"); // foreground