/* FILENAME : notify_touchy.c DESCRIPTION : Service which touches a file to vrffile if the return code of program is status_ok. AUTHOR : Bandie DATE : 2018-03-17T20:31:48+01:00 LICENSE : GNU-GPLv3 */ #include #include #include #include #include #include #include #include #include #include #define PROGARGVSIZE 256 char *prog = NULL; void help(){ printf("notify_touchy ( arguments )\n\n" "It checks if a program has a specific return code within some time. If it has not a notification will appear.\n\n" "Arguments:\n\n" "-h, --help Shows this here.\n" "-p, --program [program or script] Executes and checks this program for the return code. (Required)\n" "-r, --return [return code] Listen to this return code. (Default: 0)\n" "-s, --sleep [seconds] Interval of when the next check should start. (Default: 20)\n" "-v, --verbose Show some unnecessary stuff.\n\n"); } void exec_failed(){ fprintf(stderr, "ERROR: It is not possible to execute %s: ", prog); if(access(prog, F_OK)) fprintf(stderr, "It does not exist (in your PATH variable).\n"); else fprintf(stderr, "Access denied. (Are you root?)\n"); exit(EXIT_FAILURE); } void sig_handler(int signo){ if(signo == SIGTERM || signo == SIGINT){ exit(0); } } int main(int argc, char *argv[]){ int returncode = 0; int sleeptm = 20; int verbose = 0; int statval; char *progargv[PROGARGVSIZE]; // Argument handling for(int i=0; i