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

Function subd_shutdown

lightningd/subd.c:872–903  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

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

Tested by

no test coverage detected