stopdaemon.c (1256B)
1 /************************************************************************* 2 * This file is part of Crosroads 1.23, a load balancer and fail over 3 * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. 4 * Visit http://crossroads.e-tunity.com for information. 5 *************************************************************************/ 6 #include "crossroads.h" 7 8 int stop_daemon (int ac, char **av) { 9 int i, result = 0; 10 11 for (i = 0; i < nservice; i++) { 12 alloc_reporter (service + i, 0); 13 msg ("Stopping service %s (daemon pid %d, wakeup handler pid %d)", 14 service[i].name, servicereport->pid, servicereport->rev_pid); 15 if (kill (servicereport->pid, SIGINT)) { 16 warning ("Failed to stop service %s (%s)", 17 service[i].name, strerror(errno)); 18 result++; 19 } else if (servicereport->rev_pid && 20 kill (servicereport->rev_pid, SIGINT)) { 21 warning ("Failed to stop wakeup handler of service %s (%s)", 22 service[i].name, strerror(errno)); 23 result++; 24 } 25 26 /* Note: We run the deallocator of shmem here anyeay, though the 27 * signalled listener does it too.. just to make sure.. We do this 28 * only if above kills have succeeded. 29 */ 30 if (!result) 31 dealloc_reporter (service + i); 32 } 33 34 return (1); 35 }