MCPcopy Create free account
hub / github.com/ElementsProject/lightning / subd_shutdown

Function subd_shutdown

lightningd/subd.c:883–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881}
882
883struct subd *subd_shutdown(struct subd *sd, unsigned int seconds)
884{
885 struct sigaction sa, old;
886
887 log_debug(sd->log, "Shutting down");
888
889 tal_del_destructor(sd, destroy_subd);
890
891 /* This should make it exit; steal so it stays around. */
892 tal_steal(sd->ld, sd);
893 sd->conn = tal_free(sd->conn);
894
895 /* Set up alarm to wake us up if child doesn't exit. */
896 sa.sa_handler = discard_alarm;
897 sigemptyset(&sa.sa_mask);
898 sa.sa_flags = 0;
899 sigaction(SIGALRM, &sa, &old);
900 alarm(seconds);
901
902 if (waitpid(sd->pid, NULL, 0) > 0) {
903 alarm(0);
904 sigaction(SIGALRM, &old, NULL);
905 list_del_from(&sd->ld->subds, &sd->list);
906 return tal_free(sd);
907 }
908
909 sigaction(SIGALRM, &old, NULL);
910 /* Didn't die? This will kill it harder */
911 sd->must_not_exit = false;
912 destroy_subd(sd);
913 return tal_free(sd);
914}
915
916void subd_shutdown_nonglobals(struct lightningd *ld)
917{

Callers 1

Calls 4

tal_freeFunction · 0.85
list_del_fromFunction · 0.85
destroy_subdFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected