sysmgr

a simplistic service supervisor (deprecated)
git clone git://git.ckyln.com/~cem/sysmgr.git
Log | Files | Refs | README | LICENSE

checkprocess.c (440B)


      1 /* See LICENSE for copyright information */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <signal.h>
      5 #include <libgen.h>
      6 
      7 #include "util.h"
      8 
      9 static char *argv0;
     10 
     11 void
     12 usage(void)
     13 {
     14 	fprintf(stderr, "usage: %s [pid]\n", argv0);
     15 	exit(1);
     16 }
     17 
     18 int
     19 main(int argc, char *argv[])
     20 {
     21 	argv0 = basename(argv[0]);
     22 	int pid;
     23 
     24 	if (!argv[1] || sscanf(argv[1], "%d", &pid) != 1)
     25 		usage();
     26 
     27 	if (checkprocess(pid) == 0)
     28 		return 0;
     29 	else
     30 		return 1;
     31 }